Commit Graph

35121 Commits

Author SHA1 Message Date
Tom Tromey d8be293957 properly parenthesize two macros
I happened to notice that a couple of macros in target.h weren't
properly using parens and as a result had a strange definition.

This patch adds the parens and then fixes the macros to be written as
must have been intended.

Tested by rebuilding.
I'm pushing this as obvious.

2014-07-25  Tom Tromey  <tromey@redhat.com>

	* target.h (target_stopped_data_address)
	(target_watchpoint_addr_within_range): Use "->", not ".".  Fix
	parentheses.
2014-07-25 09:20:03 -06:00
Pierre Langlois 7d0d9d2bee Clarify the address and pointer conversions on AVR.
This patch adds additional comments about the conversion of addresses to
pointers and vice-versa on AVR.

Special conversion needs to be done when dealing with an address in the
flash address space, where both code and read-only data can be stored.
Code and data pointers to flash are not addressed the same way:

A code pointer is 16 bit addressed.  A data pointer is 8 bit addressed,
even if the data is in flash.

2014-07-25  Pierre Langlois  <pierre.langlois@embecosm.com>

	* avr-tdep.c (avr_address_to_pointer): Clarify the conversion in the
	comments.
	(avr_pointer_to_address): Likewise.
2014-07-25 15:03:29 +01:00
Pedro Alves c3f814a143 Fix paginate-*.exp races
Jan pointed out in
<https://sourceware.org/ml/gdb-patches/2014-07/msg00553.html> that
these testcases have racy results:

  gdb.base/double-prompt-target-event-error.exp
  gdb.base/paginate-after-ctrl-c-running.exp
  gdb.base/paginate-bg-execution.exp
  gdb.base/paginate-execution-startup.exp
  gdb.base/paginate-inferior-exit.exp

This is easily reproducible with "read1" from:

  [reproducer for races of expect incomplete reads]
  http://sourceware.org/bugzilla/show_bug.cgi?id=12649

The '-notransfer -re "<return>" { exp_continue }' trick in the current
tests doesn't actually work.

The issue that led to the -notransfer trick was that

  "---Type <return> to continue, or q <return> to quit---"

has two "<return>"s.  If one wants gdb_test_multiple to not hit the
built-in "<return>" match that results in FAIL, one has to expect the
pagination prompt in chunks, first up to the first "<return>", then
again, up to the second.  Something around these lines:

  gdb_test_multiple "" $test {
      -re "<return>" {
	  exp_continue
      }
      -re "to quit ---" {
	  pass $test
      }
  }

The intent was for -notransfer+exp_continue to make expect fetch more
input, and rerun the matches against the now potentially fuller
buffer, and then eventually the -re that includes the full pagination
prompt regex would match instead (because it's listed higher up, it
would match first).  But, once that "<return>" -notransfer -re
matches, it keeps re-matching forever.  It seems like with
exp_continue, expect immediately retries matching, instead of first
reading in more data into the buffer, if available.

Fix this like I should have done in the first place.  There's actually
no good reason for gdb_test_multiple to only match "<return>".  We can
make gdb_test_multiple expect the whole pagination prompt text
instead, which is store in the 'pagination_prompt' global (similar to
'gdb_prompt').  Then a gdb_test_multiple caller that doesn't want the
default match to trigger, because it wants to see one pagination
prompt, does simply:

  gdb_test_multiple "" $test {
      -re "$pagination_prompt$" {
	  pass $test
      }
  }

which is just like when we don't want the default $gdb_prompt match
within gdb_test_multiple to trigger, like:

  gdb_test_multiple "" $test {
      -re "$gdb_prompt $" {
	  pass $test
      }
  }

Tested on x86_64 Fedora 20.  In addition, I've let the racy tests run
all in parallel in a loop for 30 minutes, and they never failed.

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

	* gdb.base/double-prompt-target-event-error.exp
	(cancel_pagination_in_target_event): Remove '-notransfer <return>'
	match.
	(cancel_pagination_in_target_event): Rework double prompt
	detection.
	* gdb.base/paginate-after-ctrl-c-running.exp
	(test_ctrlc_while_target_running_paginates): Remove '-notransfer
	<return>' match.
	* gdb.base/paginate-bg-execution.exp
	(test_bg_execution_pagination_return)
	(test_bg_execution_pagination_cancel): Remove '-notransfer
	<return>' matches.
	* gdb.base/paginate-execution-startup.exp
	(test_fg_execution_pagination_return)
	(test_fg_execution_pagination_cancel): Remove '-notransfer
	<return>' matches.
	* gdb.base/paginate-inferior-exit.exp
	(test_paginate_inferior_exited): Remove '-notransfer <return>'
	match.
	* lib/gdb-utils.exp (string_to_regexp): Move here from lib/gdb.exp.
	* lib/gdb.exp (pagination_prompt): Run text through
	string_to_regexp.
	(gdb_test_multiple): Match $pagination_prompt instead of
	"<return>".
	(string_to_regexp): Move to lib/gdb-utils.exp.
2014-07-25 10:07:38 +01:00
Tom Tromey e9e7f72405 constify target fields
This constifies the target_ops fields to_shortname, to_longname, and
to_doc.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* monitor.c (compile_pattern): Update.
	* target.h (struct target_ops) <to_shortname, to_longname,
	to_doc>: Now const.
2014-07-24 11:30:04 -06:00
Tom Tromey 1947513d92 constify command docs
This makes the command "doc" parameter const.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.c (add_cmd, add_prefix_cmd)
	(add_abbrev_prefix_cmd, add_set_or_show_cmd, add_info)
	(add_info_alias, add_com): Make "doc" const.
	(print_doc_line): Make "str" const.
	(delete_cmd): Update.
	* cli/cli-decode.h (struct cmd_list_element) <doc>: Now const.
	(print_doc_line): Update.
	* cli/cli-script.c (document_command): Update.
	* command.h (add_cmd, add_prefix_cmd, add_abbrev_prefix_cmd)
	(add_com, add_info, add_info_alias): Update.
	* guile/scm-cmd.c (cmdscm_destroyer): Update.
	* python/py-cmd.c (cmdpy_destroyer): Update.
2014-07-24 11:30:04 -06:00
Tom Tromey 64e61d290e constify command prefix
This constifies the "prefix" argument to the various command-adding
functions.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.c (print_help_for_command): Make "prefix" const.
	(add_prefix_cmd, add_abbrev_prefix_cmd, apropos_cmd, help_list)
	(help_cmd_list): Constify.
	(lookup_cmd): Update.
	* cli/cli-decode.h (struct cmd_list_element) <prefixname>: Now
	const.
	(help_cmd_list, apropos_cmd): Update.
	* cli/cli-script.c (show_user): Update.
	* cli/cli-setshow.c (cmd_show_list): Make "prefix" const.
	* cli/cli-setshow.h (cmd_show_list): Update.
	* command.h (add_prefix_cmd, add_abbrev_prefix_cmd, help_list)
	(cmd_show_list): Update.
	* guile/scm-cmd.c (cmdscm_destroyer): Update.
	* python/py-cmd.c (cmdpy_destroyer): Update.
2014-07-24 11:30:04 -06:00
Tom Tromey 429e55ea94 constify deprecate_cmd
This constifies deprecate_cmd and the "replacement" field in struct
cmd_list_element.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.c (deprecate_cmd): Make "replacement" const.
	* cli/cli-decode.h (struct cmd_list_element) <replacement>: Now
	const.
	* command.h (deprecate_cmd): Update.
	* maint.c (maintenance_do_deprecate): Add casts.
2014-07-24 11:30:03 -06:00
Tom Tromey 64669f3b4b constify help_cmd
This constifies help_cmd.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* cli/cli-decode.c (help_cmd): Make parameter "const".
	* cli/cli-decode.h (help_cmd): Update.
2014-07-24 11:30:03 -06:00
Tom Tromey d3d3328bca constify stack.c
This constifies a couple of functions in stack.c.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* stack.c (up_silently_base, down_silently_base): Make argument
	const.
2014-07-24 11:30:03 -06:00
Tom Tromey 414842dc7a constify solib_add
This constifies the "pattern" argument to solib_add.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* solib.c (solib_add): Make "pattern" const.
	* solib.h (solib_add): Update.
2014-07-24 11:30:02 -06:00
Tom Tromey baa336ce7b constify remote.c
This does some more constification in remote.c.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* remote.c (remote_serial_open, print_packet, putpkt)
	(putpkt_binary): Constify.
	* remote.h (putpkt): Update.
2014-07-24 11:30:02 -06:00
Tom Tromey 5a19e2d0fe constify monitor_open
This constifies an argument to monitor_open.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* monitor.c (monitor_open): Make "args" const.
	* monitor.h (monitor_open): Update.
2014-07-24 11:30:02 -06:00
Tom Tromey fc4baa5e1f constify maint.c
This does a bit of constification in maint.c, making
print_bfd_section_info a bit cleaner in the process.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* maint.c (match_bfd_flags): Make "string" const.
	(print_bfd_section_info): Remove casts.
	(print_objfile_section_info): Make "string" const.
2014-07-24 11:30:02 -06:00
Tom Tromey 0d5f0dbeb0 constify inf_child_open_target
This constifies an argument to inf_child_open_target.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* inf-child.c (inf_child_open_target): Make "arg" const.
	* inf-child.h (inf_child_open_target): Update.
2014-07-24 11:30:02 -06:00
Tom Tromey 41c7789967 constify unset_in_environ
This constifies an argument to unset_in_environ.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* environ.c (unset_in_environ): Make "var" const.
	* environ.h (unset_in_environ): Update.
2014-07-24 11:30:02 -06:00
Tom Tromey 93db0d79de constify cli-dump.c
This does some minor constification in cli-dump.c.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* cli/cli-dump.c (scan_expression_with_cleanup): Return const.
	Make "cmd" const.
	(scan_filename_with_cleanup): Likewise.
	(dump_memory_to_file, dump_value_to_file, restore_binary_file):
	Make arguments const.
	(restore_command): Update.
2014-07-24 11:30:01 -06:00
Pedro Alves 36d6eb95c1 Fix pagination crash when the TUI is active
The TUI currently crashes when the user types <return> in response to
a pagination prompt:

  $ gdb --tui ...
  *the TUI is now active*
  (gdb) set height 2
  (gdb) help
  List of classes of commands:

  Program received signal SIGSEGV, Segmentation fault.
  strlen () at ../sysdeps/x86_64/strlen.S:106
  106             movdqu  (%rax), %xmm12

  (top-gdb) bt
  #0  strlen () at ../sysdeps/x86_64/strlen.S:106
  #1  0x000000000086be5f in xstrdup (s=0x0) at ../src/libiberty/xstrdup.c:33
  #2  0x00000000005163f9 in tui_prep_terminal (notused1=1) at ../src/gdb/tui/tui-io.c:296
  #3  0x000000000077a7ee in _rl_callback_newline () at ../src/readline/callback.c:82
  #4  0x000000000077a853 in rl_callback_handler_install (prompt=0x0, linefunc=0x618b60 <command_line_handler>) at ../src/readline/callback.c:102
  #5  0x0000000000718a5c in gdb_readline_wrapper_cleanup (arg=0xfd14d0) at ../src/gdb/top.c:788
  #6  0x0000000000596d08 in do_my_cleanups (pmy_chain=0xcf0b38 <cleanup_chain>, old_chain=0x1043d10) at ../src/gdb/cleanups.c:155
  #7  0x0000000000596d75 in do_cleanups (old_chain=0x1043d10) at ../src/gdb/cleanups.c:177
  #8  0x0000000000718bd9 in gdb_readline_wrapper (prompt=0x7fffffffcfa0 "---Type <return> to continue, or q <return> to quit---")
      at ../src/gdb/top.c:835
  #9  0x000000000071cf74 in prompt_for_continue () at ../src/gdb/utils.c:1894
  #10 0x000000000071d434 in fputs_maybe_filtered (linebuffer=0x1043db0 "List of classes of commands:\n\n", stream=0xf72e20, filter=1)
      at ../src/gdb/utils.c:2111
  #11 0x000000000071da0f in vfprintf_maybe_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118, filter=1)
      at ../src/gdb/utils.c:2339
  #12 0x000000000071da4a in vfprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118)
      at ../src/gdb/utils.c:2347
  #13 0x000000000071dc72 in fprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n") at ../src/gdb/utils.c:2399
  #14 0x00000000004f90ab in help_list (list=0xe6d100, cmdtype=0x89ad8c "", class=all_classes, stream=0xf72e20)
      at ../src/gdb/cli/cli-decode.c:1038
  #15 0x00000000004f8dba in help_cmd (arg=0x0, stream=0xf72e20) at ../src/gdb/cli/cli-decode.c:946

Git 0017922 added:

    @@ -776,6 +777,12 @@ gdb_readline_wrapper_cleanup (void *arg)

     gdb_assert (input_handler == gdb_readline_wrapper_line);
     input_handler = cleanup->handler_orig;
  +
  +  /* Reinstall INPUT_HANDLER in readline, without displaying a
  +     prompt.  */
  +  if (async_command_editing_p)
  +    rl_callback_handler_install (NULL, input_handler);

and tui_prep_terminal simply misses handling the case of a NULL
rl_prompt.

I also checked that readline's sources do similar checks.

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

	* tui/tui-io.c (tui_prep_terminal): Handle NULL rl_prompt.
2014-07-24 15:51:21 +01:00
Tom Tromey 8009206ae2 Remove some GDBSERVER checks from linux-ptrace
This patch removes some GDBSERVER checks from nat/linux-ptrace.c.
Currently the code uses a compile-time check to decide whether some
flags should be used.  This changes the code to instead let users of
the module specify an additional set of flags; and then changes gdb's
linux-nat.c to call this function.  At some later date, when the back
ends are fully merged, we will be able to remove this function again.

gdb/
2014-07-24  Tom Tromey  <tromey@redhat.com>
	    Gary Benson  <gbenson@redhat.com>

	* nat/linux-ptrace.c (additional_flags): New global.
	(linux_test_for_tracesysgood, linux_test_for_tracefork): Use
	additional_flags; don't check GDBSERVER.
	(linux_ptrace_set_additional_flags): New function.
	* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
	Declare.
	* linux-nat.c (_initialize_linux_nat): Call
	linux_ptrace_set_additional_flags.
2014-07-24 15:06:39 +01:00
Tom Tromey 314c6a3559 Make gdbserver CORE_ADDR unsigned
gdbserver defines CORE_ADDR to be signed.  This seems erroneous to
me; and furthermore likely to cause problems in common/, as it is
different from gdb's definition.

gdb/gdbserver/
2014-07-24  Tom Tromey  <tromey@redhat.com>
	    Gary Benson  <gbenson@redhat.com>

	* server.h (CORE_ADDR): Now unsigned.
2014-07-24 14:57:25 +01:00
Tom Tromey a7068b6012 auto-generate most target debug methods
The target debug methods are inconsistently maintained.  Most to_*
methods have some kind of targetdebug awareness, but not all of them
do.  The ones that do vary in the quantity and quality of output they
generate.

This patch changes most of the target debug methods to be
automatically generated.  All the arguments are printed, and separate
lines are printed for entering and existing the outermost call to the
target stack.

For example now you'd see:

    -> multi-thread->to_terminal_ours (...)
    -> multi-thread->to_is_async_p (...)
    <- multi-thread->to_is_async_p (0x1ebb580) = 1
    <- multi-thread->to_terminal_ours (0x1ebb580)
    -> multi-thread->to_thread_address_space (...)
    <- multi-thread->to_thread_address_space (0x1ebb580, 26802) = 1

In this case you can see nested calls.  The "multi-thread" on the left
hand side is the topmost target's shortname.

There are some oddities with this patch.  I'm on the fence about it
all, I really just wrote it on a whim.

It's not simple to convert every possible method, since a few don't
participate in target delegation.

Printing is done by type, so I introduced some new
debug-printing-specific typedefs to handle cases where it is nicer to
do something else.

On the plus side, this lays the groundwork for making targetdebug
affect every layer of the target stack.  The idea would be to wrap
each target_ops in the stack with its own debug_target, and then you
could see calls propagate down the stack and back up; I suppose with
indentation to make it prettier.  (That said there are some gotchas
lurking in this idea due to target stack introspection.)

Regtested on x86-64 Fedora 20.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* make-target-delegates (munge_type, write_debugmethod): New
	functions.
	(debug_names): New global.
	($TARGET_DEBUG_PRINTER): New global.
	(write_function_header): Strip TARGET_DEBUG_PRINTER from the type
	name.
	Write debug methods.  Generate init_debug_target.
	* target-debug.h: New file.
	* target-delegates.c: Rebuild.
	* target.c: Include target-debug.h.
	(debug_target): Hoist definition.
	(target_kill, target_get_section_table, target_memory_map)
	(target_flash_erase, target_flash_done, target_detach)
	(target_disconnect, target_wait, target_resume)
	(target_pass_signals, target_program_signals, target_follow_fork)
	(target_mourn_inferior, target_search_memory)
	(target_thread_address_space, target_close)
	(target_find_new_threads, target_core_of_thread)
	(target_verify_memory, target_insert_mask_watchpoint)
	(target_remove_mask_watchpoint): Remove targetdebug code.
	(debug_to_post_attach, debug_to_prepare_to_store)
	(debug_to_files_info, debug_to_insert_breakpoint)
	(debug_to_remove_breakpoint, debug_to_can_use_hw_breakpoint)
	(debug_to_region_ok_for_hw_watchpoint)
	(debug_to_can_accel_watchpoint_condition)
	(debug_to_stopped_by_watchpoint, debug_to_stopped_data_address)
	(debug_to_watchpoint_addr_within_range)
	(debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint)
	(debug_to_insert_watchpoint, debug_to_remove_watchpoint)
	(debug_to_terminal_init, debug_to_terminal_inferior)
	(debug_to_terminal_ours_for_output, debug_to_terminal_ours)
	(debug_to_terminal_save_ours, debug_to_terminal_info)
	(debug_to_load, debug_to_post_startup_inferior)
	(debug_to_insert_fork_catchpoint)
	(debug_to_remove_fork_catchpoint)
	(debug_to_insert_vfork_catchpoint)
	(debug_to_remove_vfork_catchpoint)
	(debug_to_insert_exec_catchpoint)
	(debug_to_remove_exec_catchpoint, debug_to_has_exited)
	(debug_to_can_run, debug_to_thread_architecture, debug_to_stop)
	(debug_to_rcmd, debug_to_pid_to_exec_file): Remove.
	(setup_target_debug): Call init_debug_target.
	* target.h (TARGET_DEBUG_PRINTER): New macro.
	(struct target_ops) <to_resume, to_wait, to_pass_signals,
	to_program_signals>: Use TARGET_DEBUG_PRINTER.
2014-07-24 07:39:47 -06:00
Gary Benson 2c51604d3a Rationalize "fatal" error handling outside of gdbserver
GDB and gdbserver have functions named "fatal" that are used in
completely different ways.  In gdbserver "fatal" is used to handle
critical errors: it differs from "error" in that "fatal" causes
gdbserver to exit whereas "error" does not.  In GDB "fatal" is used
to abort the current operation and return to the command level.
This is implemented by throwing a non-error "RETURN_QUIT" exception.

This commit removes GDB's "fatal" and "vfatal" functions entirely.
The exception-throwing function "throw_vfatal" is renamed as
"throw_vquit", and a new convenience function "throw_quit" is added.
The small number of calls to "fatal" are replaced with calls to
"throw_quit", making what is happening more obvious.

This commit also modifies GDB's "throw_error" to call "throw_verror"
rather than calling "throw_it" directly.  This change means the
assignment of RETURN_ERROR as the exception type now happens in
precisely one place in GDB rather than two.

gdb/
2014-07-24  Gary Benson  <gbenson@redhat.com>

	* exceptions.h (throw_vfatal): Renamed to...
	(throw_vquit): New declaration.
	(throw_quit): Likewise.
	* exceptions.c (throw_vfatal): Renamed to...
	(throw_vquit): New function.
	(throw_quit): Likewise.
	(throw_error): Call throw_verror rather than throw_it.
	* utils.h (vfatal): Removed.
	(fatal): Likewise.
	* utils.c (vfatal): Removed.
	(fatal): Likewise.
	(internal_verror): Replaced call to fatal with call to throw_quit.
	(quit): Replaced calls to fatal with calls to throw_quit.
2014-07-24 09:55:50 +01:00
Michael Eager 342119630e This patch uses target_read_code instead of target_read_memory in
microblaze_fetch instruction in order to use cache memory accesses
requested in target_read_code.

ChangeLog:
2014-06-17 Ajit Agarwal <ajitkum@xilinx.com>

	* microblaze-tdep.c (microblaze_fetch_instruction): Use of
	target_read_code.
2014-07-23 19:27:20 -07:00
Michael Eager a52b4d3e26 se typecast 'size_t' on 'reg', not only avoid the related warning, but
also check whether less than zero -- for 'reg' is type 'int', and sizeof
(dwarf2_to_reg_map) is less than 0x7fff.

It is quoted in gdb_assert(), so need check 'reg' whether less than zero.
And the related warning (with '-W'):

  ../../binutils-gdb/gdb/microblaze-tdep.c:667:3: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

ChangeLog:

 * microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Check whether
 less tha zero in conditional expression.
2014-07-23 19:21:42 -07:00
Tom Tromey a8bdc56b4e rewrite make-target-delegates matching code
This patch rewrites the make-target-delegates matching code a little
bit.  The result is functionally the same (the output has some small
whitespace differences), but the new code is more forgiving regarding
the formatting of target.h.  In particular now there's no need to
ensure that the return type and the method name appear on the same
line.

2014-07-23  Tom Tromey  <tromey@redhat.com>

	* make-target-delegates ($ARGS_PART): Match trailing close paren.
	($INTRO_PART): Don't match whitespace.
	($METHOD_TRAILER): Move earlier.  Remove trailing semicolon and
	argument matching.
	($METHOD): Add $METHOD_TRAILER.
	(trim): Rewrite.
	(scan_target_h): New sub.
	Change main loop not to collect state.
	* target-delegates.c: Rebuild.
2014-07-23 10:01:27 -06:00
Gary Benson 91b522404e Fix build on systems without sigaltstack.
This commit fixes the build on systems without sigaltstack.

gdb/
2014-07-23  Gary Benson  <gbenson@redhat.com>

	* cp-support.c (gdb_demangle): Fix build on systems without
	sigaltstack.
2014-07-23 15:25:05 +01:00
Jan Kratochvil 45326f6fbe Remove setting value address for reference entry value target data value.
I cannot reproduce any wrong case having the code removed.

I just do not find it correct to have it disabled.  But at the same time I do
like much / I do not find correct the code myself.  It is a bit problematic to
have struct value describing a memory content which is no longer present
there.

What happens there:
------------------------------------------------------------------------------
volatile int vv;
static __attribute__((noinline)) int
bar (int &ref) {
  ref = 20;
  vv++; /* break-here */
  return ref;
}
int main (void) {
  int var = 10;
  return bar (var);
}
------------------------------------------------------------------------------
 <4><c7>: Abbrev Number: 13 (DW_TAG_GNU_call_site_parameter)
    <c8>   DW_AT_location    : 1 byte block: 55         (DW_OP_reg5 (rdi))
    <ca>   DW_AT_GNU_call_site_value: 2 byte block: 91 74       (DW_OP_fbreg: -12)
    <cd>   DW_AT_GNU_call_site_data_value: 1 byte block: 3a     (DW_OP_lit10)
------------------------------------------------------------------------------
gdb -ex 'b value_addr' -ex r --args ../gdb ./1 -ex 'watch vv' -ex r -ex 'p &ref@entry'
->
6    return ref;
bar (ref=@0x7fffffffd944: 20, ref@entry=@0x7fffffffd944: 10) at 1.C:25
------------------------------------------------------------------------------
At /* break-here */ struct value variable 'ref' is TYPE_CODE_REF.

With FSF GDB HEAD:
(gdb) x/gx arg1.contents
0x6004000a4ad0: 0x00007fffffffd944
(gdb) p ((struct value *)arg1.location.computed.closure).lval
$1 = lval_memory
(gdb) p/x ((struct value *)arg1.location.computed.closure).location.address
$3 = 0x7fffffffd944

With your #if0-ed code:
(gdb) x/gx arg1.contents
0x6004000a4ad0: 0x00007fffffffd944
(gdb) p ((struct value *)arg1.location.computed.closure).lval
$8 = not_lval
(gdb) p/x ((struct value *)arg1.location.computed.closure).location.address
$9 = 0x0

I do not see how to access
        ((struct value *)arg1.location.computed.closure).location.address
from GDB CLI.  Trying
(gdb) p &ref@entry
will invoke value_addr()'s:
  if (TYPE_CODE (type) == TYPE_CODE_REF)
      /* Copy the value, but change the type from (T&) to (T*).  We
         keep the same location information, which is efficient, and
         allows &(&X) to get the location containing the reference.  */
and therefore the address gets fetched already from
  arg1.contents
and not from
  ((struct value *)arg1.location.computed.closure).location.address
.

And for any other type than TYPE_CODE_REF this code you removed does not get
executed at all.  This DW_AT_GNU_call_site_data_value DWARF was meant
primarily for Fortran but with -O0 entry values do not get produced
and with -Og and higher Fortran always optimizes out the passing by reference.

If you do not like the removed code there I am OK with removing it as I do not
know how to make it's use reproducible for user anyway.  In the worst case
- if there really is some way how to exploit it - one should just get
  Attempt to take address of value not located in memory.
instead of some wrong value and it may be easy to fix then.

gdb/
2014-07-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2loc.c (value_of_dwarf_reg_entry): Remove setting value address
	for reference entry value target data value.

Message-ID: <20140720150727.GA18488@host2.jankratochvil.net>
2014-07-22 22:15:27 +02:00
Jan Kratochvil e214cf6c2e Fix read_frame_arg for optimized-out entry values.
gdb/
2014-07-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* stack.c (read_frame_arg): Verify value_optimized_out before calling
	value_available_contents_eq.

gdb/testsuite/
2014-07-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/amd64-entry-value-paramref.S: New file.
	* gdb.arch/amd64-entry-value-paramref.cc: New file.
	* gdb.arch/amd64-entry-value-paramref.exp: New file.
	* gdb.arch/amd64-optimout-repeat.S: New file.
	* gdb.arch/amd64-optimout-repeat.c: New file.
	* gdb.arch/amd64-optimout-repeat.exp: New file.

Message-ID: <20140720150727.GA18488@host2.jankratochvil.net>
Message-ID: <20140711153757.GA452@host2.jankratochvil.net>
2014-07-22 22:09:35 +02:00
Pedro Alves bddbbedd70 Fix crash on optimized-out entry data values
The tests at
<https://sourceware.org/ml/gdb-patches/2014-07/msg00277.html> show
that comparing a fully optimized out value's contents with a value
that has not been optimized out, or is partially optimized out crashes
GDB:

 (gdb) bt
 #0  __memcmp_sse4_1 () at ../sysdeps/x86_64/multiarch/memcmp-sse4.S:816
 #1  0x00000000005a1914 in memcmp_with_bit_offsets (ptr1=0x202b2f0 "\n", offset1_bits=0, ptr2=0x0, offset2_bits=0, length_bits=32)
     at /home/pedro/gdb/mygit/build/../src/gdb/value.c:678
 #2  0x00000000005a1a05 in value_available_contents_bits_eq (val1=0x2361ad0, offset1=0, val2=0x23683b0, offset2=0, length=32)
     at /home/pedro/gdb/mygit/build/../src/gdb/value.c:717
 #3  0x00000000005a1c09 in value_available_contents_eq (val1=0x2361ad0, offset1=0, val2=0x23683b0, offset2=0, length=4)
     at /home/pedro/gdb/mygit/build/../src/gdb/value.c:769
 #4  0x00000000006033ed in read_frame_arg (sym=0x1b78d20, frame=0x19bca50, argp=0x7fff4aba82b0, entryargp=0x7fff4aba82d0)
     at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:416
 #5  0x0000000000603abb in print_frame_args (func=0x1b78cb0, frame=0x19bca50, num=-1, stream=0x1aea450) at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:671
 #6  0x0000000000604ae8 in print_frame (frame=0x19bca50, print_level=0, print_what=SRC_AND_LOC, print_args=1, sal=...)
     at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:1205
 #7  0x0000000000604050 in print_frame_info (frame=0x19bca50, print_level=0, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1)
     at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:857
 #8  0x00000000006029b3 in print_stack_frame (frame=0x19bca50, print_level=0, print_what=SRC_AND_LOC, set_current_sal=1)
     at /home/pedro/gdb/mygit/build/../src/gdb/stack.c:169
 #9  0x00000000005fc4b8 in print_stop_event (ws=0x7fff4aba8790) at /home/pedro/gdb/mygit/build/../src/gdb/infrun.c:6068
 #10 0x00000000005fc830 in normal_stop () at /home/pedro/gdb/mygit/build/../src/gdb/infrun.c:6214

The 'ptr2=0x0' in frame #1 is val2->contents, and since git 4f14910f:

    gdb/ChangeLog
    2013-11-26  Andrew Burgess  <aburgess@broadcom.com>

        * value.c (allocate_optimized_out_value): Mark value as non-lazy.

... a fully optimized-out value can have it's value contents buffer
NULL.

As a spotgap fix, revert 4f14910f, with a comment.  A full fix would
be too invasive for 7.8.

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

	* value.c (allocate_optimized_out_value): Don't mark value as
	non-lazy.
2014-07-22 19:56:28 +01:00
Jiong Wang 50d13ae760 Fix typo in my email address. 2014-07-22 16:22:50 +01:00
Jiong Wang 45c7148402 Update email address in gdb MAINTAINERS list. 2014-07-22 16:18:02 +01:00
Doug Evans 9597b22adf Improve error message to cope with pr 17147.
PR server/17147
	* remote.c (putpkt_binary): Add text to error message.
2014-07-20 15:36:23 -07:00
Yao Qi 91101fe524 Remove Chill from comments
gdb:

2014-07-20  Yao Qi  <yao@codesourcery.com>

	* eval.c: Remove "Chill" from comments.
	* gdbtypes.h: Likewise.
	* symtab.h: Likewise.
2014-07-21 03:46:49 +08:00
Yao Qi c9402c9579 Update comments to TERNOP_SLICE
TERNOP_SLICE was added for language Chill, but it is used for Ada and D later.
Since language Chill was removed from GDB, TERNOP_SLICE is only used for
Ada and D.  This patch is to update its comments.

gdb:

2014-07-20  Yao Qi  <yao@codesourcery.com>

	* std-operator.def: Update comments to TERNOP_SLICE.
2014-07-21 03:46:43 +08:00
Yao Qi ae8fddda32 Remove operator BINOP_RANGE
BINOP_RANGE was added by the following commit for chill language.

commit badefd2800
Author: Per Bothner <per@bothner.com>
Date:   Wed Nov 29 22:59:31 1995 +0000

        * expression.h (enum exp_opcode):  Add BINOP_RANGE.
        * expprint.c (dump_expression):  Support BINOP_RANGE.
        * eval.c (evaluate_subexp_standard):  Handle BINOP_RANGE (as error).
        (case MULTI_SUBSCRIPT):  Fix broken f77 value->int ad hoc conversion.
        * ch-lang.c (chill_op_print_tab):  Support BINOP_RANGE.
        (evaluate_subexp_chill):  Error on BINOP_COMMA.

Chill language is no longer supported, so we can remove BINOP_RANGE too.
This patch is to remove BINOP_RANGE.

gdb:

2014-07-20  Yao Qi  <yao@codesourcery.com>

	* std-operator.def: Remove BINOP_RANGE.
	* breakpoint.c (watchpoint_exp_is_const): Update.
	* expprint.c (dump_subexp_body_standard): Likewise.
	* eval.c (init_array_element): Remove dead code.
	(evaluate_subexp_standard): Likewise.
2014-07-21 03:46:37 +08:00
Yao Qi 9c81664074 Remove operator BINOP_IN
Chill language support was removed several years ago, and BINOP_IN
isn't used for Pascal.  This patch is to remove BINOP_IN.

gdb:

2014-07-20  Yao Qi  <yao@codesourcery.com>

	* std-operator.def: Remove BINOP_IN.
	* breakpoint.c (watchpoint_exp_is_const): Update.
	* eval.c (evaluate_subexp_standard): Likewise.
	* expprint.c (dump_subexp_body_standard): Likewise.
2014-07-21 03:46:33 +08:00
Michael Eager 164224e96c Fix for remote G Packet message too long error for baremetal.
Prior to version MicroBlaze v8.10.a,EDK 13.1, XMD's gdbserver stub returned 57
registers in response to GDB's G request. Starting with version MicroBlaze
v8.10.a, EDK 13.1, XMD added the slr and shr register, for a count of 59
registers. This patch adds these registers to the expected G response. This patch
fixes the above problem for baremetal and also supports the backward compatibility.

ChangeLog:
2014-07-02  Ajit Agarwal  <ajitkum@xilinx.com>

	* microblaze-tdep.c (microblaze_register_names): Add
	the rshr and rslr register names.
	(microblaze_gdbarch_init): Use of tdesc_has_registers.
	Use of tdesc_find_feature. Use of tdesc_data_alloc.
	Use of tdesc_numbered_register. Use of
	microblaze_register_g_packet_guesses. Use of
	tdesc_use_registers. Use of set_gdbarch_register_type.
	(microblaze_register_g_packet_guesses): New.
	* microblaze-tdep.h (microblaze_reg_num): Add
	field MICROBLAZE_SLR_REGNUM MICROBLAZE_SHR_REGNUM
	MICROBLAZE_NUM_REGS and MICROBLAZE_NUM_CORE_REGS.
	(microblaze_frame_cache): Use of MICROBLAZE_NUM_REGS.
	* features/microblaze-core.xml: New file.
	* features/microblaze-stack-protect.xml: New file.
	* features/microblaze-with-stack-protect.c: New file.
	* features/microblaze-with-stack-protect.xml: New file.
	* features/microblaze.xml: New file.
	* features/microblaze.c: New file.
	* features/Makefile (microblaze-with-stack-protect): Add
	microblaze-with-stack-protect microblaze and
	microblaze-expedite.
	* regformats/microblaze-with-stack-protect.dat: New file.
	* regformats/microblaze.dat: New file.
	* doc/gdb.texinfo (MicroBlaze Features): New.

Signed-off-by:Ajit Agarwal ajitkum@xilinx.com
2014-07-19 17:47:52 -07:00
Tom Tromey e8b2341cd2 make exec_ops static
While working on some target stack changes, I noticed that exec_ops is
only used from exec.c.  This patch makes it "static".  This is cleaner
and makes it simpler to reason about the use of the target.

Tested by rebuilding.
I'm checking this in as obvious.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	* exec.c (exec_ops): Now static.
	* exec.h (exec_ops): Don't declare.
2014-07-18 09:59:31 -06:00
Tom Tromey 44e89118cb fix calls to find_target_beneath
A long time ago Pedro pointed out that there are some calls to
find_target_beneath that pass in an explicit target_ops; but which
should instead use the ops provided to the method in question.  See:

    https://sourceware.org/ml/gdb-patches/2014-01/msg00429.html

This patch is just a minor cleanup to fix all such calls.  There were
only three.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	* spu-multiarch.c (spu_region_ok_for_hw_watchpoint): Pass "self"
	to find_target_beneath.
	* ravenscar-thread.c (ravenscar_prepare_to_store): Pass "ops" to
	find_target_beneath.
	(ravenscar_mourn_inferior): Pass "self" to find_target_beneath.
2014-07-18 09:48:04 -06:00
Tom Tromey b0ed115fa5 fix PR gdb/17130
This fixes PR gdb/17130.

The bug is that some code in utils.c was not updated during the target
delegation change:

  if (job_control
      /* If there is no terminal switching for this target, then we can't
         possibly get screwed by the lack of job control.  */
      || current_target.to_terminal_ours == NULL)
    fatal ("Quit");
  else
    fatal ("Quit (expect signal SIGINT when the program is resumed)");

After the delegation change, to_terminal_ours will never be NULL.

I think this bug can be seen before the target delegation change by
enabling target debugging -- this would also cause to_terminal_ours to
be non-NULL.

The fix is to introduce a new target_supports_terminal_ours function,
that properly checks the target stack.  This is not perhaps ideal, but
I think is a reasonable-enough approach, and in keeping with some
other existing code of the same form.

This patch also fixes a similar bug in target_supports_delete_record.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	PR gdb/17130:
	* utils.c (quit): Use target_supports_terminal_ours.
	* target.h (target_supports_terminal_ours): Declare.
	* target.c (target_supports_delete_record): Don't check
	to_delete_record against NULL.
	(target_supports_terminal_ours): New function.
2014-07-18 09:48:02 -06:00
Tom Tromey e75fdfcad1 clean up some target delegation cases
This patch cleans up some minor inconsistencies in target delegation.
It's primary purpose is to avoid confusion in the code.  A few spots
were checking the "beneath" target; however this can only be NULL for
the dummy target, so such tests are not needed.  Some other spots were
iterating over the beneath targets, looking for a method
implementation.  This is not needed for methods handled by
make-target-delegates, as there is always an implementation.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	PR gdb/17130:
	* spu-multiarch.c (spu_region_ok_for_hw_watchpoint)
	(spu_fetch_registers, spu_store_registers, spu_xfer_partial)
	(spu_search_memory, spu_mourn_inferior): Simplify delegation.
	* linux-thread-db.c (thread_db_pid_to_str): Always delegate.
	* windows-nat.c (windows_xfer_partial): Always delegate.
	* record-btrace.c (record_btrace_xfer_partial): Simplify
	delegation.
	(record_btrace_fetch_registers, record_btrace_store_registers)
	(record_btrace_prepare_to_store, record_btrace_resume)
	(record_btrace_wait, record_btrace_find_new_threads)
	(record_btrace_thread_alive): Likewise.
	* procfs.c (procfs_xfer_partial): Always delegate.
	* corelow.c (core_xfer_partial): Always delegate.
	* sol-thread.c (sol_find_new_threads): Simplify delegation.
2014-07-18 09:48:01 -06:00
Tom Tromey 83814951ff move exec_make_note_section earlier
This patch moves exec_make_note_section a bit earlier in exec.c.  This
lets us remove an otherwise unnecessary forward declaration and it
also makes the file a bit more in line with other code, as now
_initialize_exec is the final function in the file.

Tested by rebuilding.
I'm committing this as obvious.

2014-07-18  Tom Tromey  <tromey@redhat.com>

	* exec.c (exec_make_note_section): Move earlier.
2014-07-18 09:35:04 -06:00
Jan Kratochvil e6cf2ae8bb PR 17170 - testcase for GDB global --statistics regression - fix up.
Add missing file to previous entry.
2014-07-17 13:59:03 +02:00
Jan Kratochvil 17d0c5c8f0 PR 17170 - testcase for GDB global --statistics regression.
gdb/testsuite/
2014-07-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR gdb/17170
	* gdb.base/statistics.exp: New file.

Message-ID: <20140712174217.GA1478@host2.jankratochvil.net>
2014-07-17 13:56:24 +02:00
Doug Evans 74b49205e0 Add reference to PR 17170 to previous entry. 2014-07-17 02:42:55 -07:00
Doug Evans b8b8facf90 Fix 17170.
* maint.c (count_symtabs_and_blocks): Handle NULL
	current_program_space.
	(report_command_stats): Check global enabled flag in addition to
	recorded enabled flag.
	(make_command_stats_cleanup): Handle msg_type == 0, startup.

	testsuite/
	* gdb.base/maint.exp: Update testing of per-command stats.
2014-07-17 02:38:32 -07:00
Pedro Alves 69ff6be55c Linux: Use kill_lwp/tkill instead of kill when killing a process
Since we use tkill everywhere, using kill to try to kill each lwp
individually looks suspiciously odd.  We should really be using tgkill
everywhere, but at least while we don't get there this makes us
consistent.

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

	* linux-low.c (linux_kill_one_lwp): Use kill_lwp, not kill.

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

	* linux-nat.c (kill_callback): Use kill_lwp, not kill.
2014-07-16 20:06:55 +01:00
Pedro Alves 1b5d0ab34c gdb.trace/tfile.c: Remove Thumb bit in one more more, general cleanup
I noticed that the existing code casts a function's address to 'long',
but that doesn't work correctly on some ABIs, like Win64, where long
is 32-bit and while pointers are 64-bit:

  func_addr = (long) &write_basic_trace_file;

Fixing that showed there's actually another place in the file that
writes a function address to file, and therefore should clear the
Thumb bit.  This commit adds a macro+function pair to centralize the
Thumb bit handling, and uses it in both places.

The rest is just enough changes to make the file build without
warnings with "-Wall -Wextra" with x86_64-w64-mingw32-gcc and
i686-w64-mingw32-gcc cross compilers, and with -m32/-m64 on x86_64
GNU/Linux.  Currently with x86_64-w64-mingw32-gcc we get:

  $ x86_64-w64-mingw32-gcc tfile.c  -Wall -DTFILE_DIR=\"\"
  tfile.c: In function 'start_trace_file':
  tfile.c:51:23: error: 'S_IRGRP' undeclared (first use in this function)
	 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
			 ^
  tfile.c:51:23: note: each undeclared identifier is reported only once for each function it appears in
  tfile.c:51:31: error: 'S_IROTH' undeclared (first use in this function)
	 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
				 ^
  tfile.c: In function 'add_memory_block':
  tfile.c:79:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     ll_x = (unsigned long) addr;
	    ^
  tfile.c: In function 'write_basic_trace_file':
  tfile.c:113:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     func_addr = (long) &write_basic_trace_file;
		 ^
  tfile.c:137:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob, sizeof (testglob));
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c:139:3: warning: passing argument 1 of 'add_memory_block' from incompatible pointer type [enabled by default]
     add_memory_block (&testglob2, 1);
     ^
  tfile.c:72:1: note: expected 'char *' but argument is of type 'int *'
   add_memory_block (char *addr, int size)
   ^
  tfile.c: In function 'write_error_trace_file':
  tfile.c:185:3: warning: implicit declaration of function 'alloca' [-Wimplicit-function-declaration]
     char *hex = alloca (len * 2 + 1);
     ^
  tfile.c:185:15: warning: incompatible implicit declaration of built-in function 'alloca' [enabled by default]
     char *hex = alloca (len * 2 + 1);
		 ^
  tfile.c:211:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
	(long) &write_basic_trace_file);
      ^

Tested on x86_64 Fedora 20, -m64 and -m32.
Tested by Yao on arm targets.

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

	* gdb.trace/tfile.c: Include unistd.h and stdint.h.
	(start_trace_file): Guard S_IRGRP and S_IROTH uses behind #ifdef.
	(tfile_write_64, tfile_write_16, tfile_write_8, tfile_write_addr)
	(tfile_write_buf): New functions.
	(add_memory_block): Rewrite using the above.
	(adjust_function_address): New function.
	(FUNCTION_ADDRESS): New macro.
	(write_basic_trace_file): Remove short_x local, and use
	tfile_write_16. Change type of func_addr local to unsigned long
	long.  Use FUNCTION_ADDRESS instead of handling the Thumb bit
	here.  Cast argument of add_memory_block to char pointer.
	(write_error_trace_file): Avoid alloca.  Use FUNCTION_ADDRESS.
	(main): Remove parameters.
	* gdb.trace/tfile.exp: Remove nowarnings.
2014-07-16 19:25:41 +01:00
Simon Marchi 4d974e8854 Add test for string evaluation with "debug expression" on
As Joel pointed out in...
https://sourceware.org/ml/gdb-patches/2014-07/msg00391.html
...it would be nice to add a test for that.

Tested on Linux x86_64 (Ubuntu 14.10).

gdb/testsuite/ChangeLog

2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>

	* gdb.base/debug-expr.exp: Test string evaluation with
	"debug expression" on.
2014-07-16 12:43:11 -04:00
Tom Tromey 252db1b5de reformat comment in target.h
A comment in target.h went past the column limit.  This patch
reformats it.  I'm pushing this as obvious.

2014-07-16  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_delete_record>: Reformat
	comment.
2014-07-16 08:09:27 -06:00
Tom Tromey a432721e61 rebuild target-delegates.c
target-delegates.c was out of date.  This patch rebuilds it.
Built and regtested on x86-64 Fedora 20.
Committed as obvious.

2014-07-16  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
2014-07-16 08:05:03 -06:00
Pedro Alves 41e9956873 gdb.base/reread.exp: Really restart GDB
The other day I noticed that default_gdb_start reuses the GDB process
if it has been spawned already:

proc default_gdb_start { } {
...
    if [info exists gdb_spawn_id] {
	return 0
    }

I was a bit surprised, and so I hacked in an error to check whether
anything is relying on it:

 + if [info exists gdb_spawn_id] {
 +    error "GDB already spawned"
 + }

And lo, that tripped on a funny buglet (see below).  The comment in
reread.exp says "Restart GDB entirely", but in reality, due to the
above, that's not what is happening, as a gdb_exit call is missing.
The test is proceeding with the previous GDB process...

I don't really want to go hunt for whether there's an odd setup out
there that assumes this in its board file or something, so for now,
I'm taking the simple route of just making the test do what it says it
does.  I think this much makes it an obvious fix.

 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 (gdb) PASS: gdb.base/reread.exp: run to foo() second time
 ERROR: tcl error sourcing ../src/gdb/testsuite/gdb.base/reread.exp.
 ERROR: GDB already spawned
     while executing
 "error "GDB already spawned""
     invoked from within
 "if [info exists gdb_spawn_id] {
	 error "GDB already spawned"
     }"
     (procedure "default_gdb_start" line 22)
     invoked from within
 "default_gdb_start"
     (procedure "gdb_start" line 2)
     invoked from within
 "gdb_start"
     invoked from within
 "if [is_remote target] {
     unsupported "second pass: GDB should check for changes before running"
 } else {

     # Put the older executable back in pl..."
     (file "../src/gdb/testsuite/gdb.base/reread.exp" line 114)
     invoked from within
 "source ../src/gdb/testsuite/gdb.base/reread.exp"
     ("uplevel" body line 1)
     invoked from within
 "uplevel #0 source ../src/gdb/testsuite/gdb.base/reread.exp"
     invoked from within
 "catch "uplevel #0 source $test_file_name""
 testcase ../src/gdb/testsuite/gdb.base/reread.exp completed in 1 seconds
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

	* gdb.base/reread.exp: Use clean_restart.
2014-07-15 17:30:34 +01:00
Pierre Langlois 487d975399 Add support for the __flash qualifier on AVR
The __flash qualifier is part of the named address spaces for AVR [1]. It
allows putting read-only data in the flash memory, normally reserved for
code.

When used together with a pointer, the DW_AT_address_class attribute is set
to 1 and allows GDB to detect that when it will be dereferenced, the data
will be loaded from the flash memory (with the LPM instruction).

We can now properly debug the following code:

~~~
const __flash char data_in_flash = 0xab;

int
main (void)
{
  const __flash char *pointer_to_flash = &data_in_flash;
}
~~~

~~~
(gdb) print pointer_to_flash
$1 = 0x1e8 <data_in_flash> "\253"
(gdb) print/x *pointer_to_flash
$2 = 0xab
(gdb) x/x pointer_to_flash
0x1e8 <data_in_flash>: 0xXXXXXXab
~~~

Whereas previously, GDB would revert to the default address space which is
RAM and mapped in higher memory:

~~~
(gdb) print pointer_to_flash
$1 = 0x8001e8 ""
~~~

[1] https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html

2014-07-15  Pierre Langlois  <pierre.langlois@embecosm.com>

gdb/
	* avr-tdep.c (AVR_TYPE_ADDRESS_CLASS_FLASH): New macro.
	(AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH): Likewise.
	(avr_address_to_pointer): Check for AVR_TYPE_ADDRESS_CLASS_FLASH.
	(avr_pointer_to_address): Likewise.
	(avr_address_class_type_flags): New function.
	(avr_address_class_type_flags_to_name): Likewise.
	(avr_address_class_name_to_type_flags): Likewise.
	(avr_gdbarch_init): Set address_class_type_flags,
	address_class_type_flags_to_name and
	address_class_name_to_type_flags.

gdb/testsuite/
	* gdb.arch/avr-flash-qualifer.c: New.
	* gdb.arch/avr-flash-qualifer.exp: New.
2014-07-15 17:03:09 +01:00
Pedro Alves 57745c903f [GDB/Linux] Avoid stale errno
The fix that went into GDBserver is also needed on the GDB side.

Although most compilers follow right-to-left evaluation order, the
order of evaluation of a function call's arguments is really
unspecified.  target_pid_to_str may well clobber errno when we get to
evaluate the third argument to fprintf_unfiltered.

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

	* linux-nat.c (kill_callback): Save errno and work with saved
	copy.
2014-07-15 16:22:14 +01:00
Simon Marchi 2d40be181f Handle OP_STRING in dump_subexp_body_standard
For some reason, OP_STRING is not handled in dump_subexp_body_standard.
This makes the output of "set debug expression 1" very bad when a string
is involved. Example:

(gdb) set debug expression 1
(gdb) print "hello"
... (random garbage, possibly segfault)

This commit handles OP_STRING and skips the appropriate number of exp
elements. The line corresponding to the string now looks like:

	    0  OP_STRING             Language-specific string type: 0

gdb/ChangeLog:

2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>

	* expprint.c (dump_subexp_body_standard): Handle OP_STRING.
2014-07-15 11:18:04 -04:00
Pedro Alves ce9e3fe795 [GDBserver] Avoid stale errno
Although most compilers follow right-to-left evaluation order, the
order of evaluation of a function call's arguments is really
unspecified.  target_pid_to_str or ptid_of may well clobber errno when
we get to evaluate the third argument to debug_printf.

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

	* linux-low.c (linux_kill_one_lwp): Save errno and work with saved
	copy.
2014-07-15 15:35:28 +01:00
Edjunior Barbosa Machado 572f65559b 2014-07-14 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
* ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Report no hardware
	breakpoint support correctly.
2014-07-14 20:18:10 -03:00
Pedro Alves cc1c52ad65 Add missing ChangeLog entry for 15cd413a
Put GDB's terminal settings into effect when paginating
gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

	* utils.c (prompt_for_continue): Call target_terminal_ours.

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

	* gdb.base/paginate-after-ctrl-c-running.c: New file.
	* gdb.base/paginate-after-ctrl-c-running.exp: New file.
2014-07-14 20:39:53 +01:00
Pedro Alves 8258415802 Put GDB's terminal settings into effect when paginating
When the target is resumed in the foreground, we put the inferior's
terminal settings into effect, and remove stdin from the event loop.
When the target stops, we put GDB's terminal settings into effect
again, and re-register stdin in the event loop, ready for user input.
The former is done by target_terminal_inferior, and the latter by
target_terminal_ours.

There's an intermediate -- target_terminal_ours_for_output -- that is
called when printing output related to target events, and we don't
know yet whether we'll stop the program.  That puts our terminal
settings into effect, enough to get proper results from our output,
but leaves input wired into the inferior.

If such output paginates, then we need the full target_terminal_ours
in order for the user to be able to provide input to answer the
pagination query.

The test in this commit hangs in async-capable targets without the fix
(as the user/test can't answer the pagination query).  It doesn't hang
on sync targets because on those we don't unregister stdin from the
event loop while the target is running (because we block in
target_wait instead of in the event loop in that case).

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

	* utils.c (prompt_for_continue): Call target_terminal_ours.

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

	* gdb.base/paginate-after-ctrl-c-running.c: New file.
 	* gdb.base/paginate-after-ctrl-c-running.exp: New file.
2014-07-14 20:35:31 +01:00
Pedro Alves 1e9735707b Fix double prompt
If an error is thrown while handling a target event (within
fetch_inferior_event), and, the interpreter is not async (but the
target is), then GDB prints the prompt twice.

One way to see that in action is throw a QUIT while in a pagination
prompt issued from within fetch_inferior_event (or one of its
callees).  E.g. from the test:

 ---Type <return> to continue, or q <return> to quit---
 ^CQuit
 (gdb) (gdb) p 1
 ^^^^^^^^^^^
 $1 = 1
 (gdb)

The issue is that inferior_event_handler swallows errors and notifies
the observers (the interpreters) about the command error, even if the
interpreter is forced sync while we're handling a nested event loop
(for execute_command).  The observers print a prompt, and then when we
get back to the top event loop, we print another (in
start_event_loop).

I see no reason the error should be swallowed here.  Just cancel the
execution related bits and let the error propagate to the top level
(start_event_loop), which re-enables stdin and notifies observers.

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

	* inf-loop.c (inferior_event_handler): Use TRY_CATCH instead of
	catch_errors.  Don't re-enable stdin or notify observers where,
	and rethrow error.
	(fetch_inferior_event_wrapper): Delete.

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

	* gdb.base/double-prompt-target-event-error.c: New file.
	* gdb.base/double-prompt-target-event-error.exp: New file.
2014-07-14 20:34:23 +01:00
Pedro Alves 93d6eb10ed Remove the target from the event loop while in secondary prompts
If a pagination prompt triggers while the target is running, and the
target exits before the user responded to the pagination query, this
happens:

  Starting program: foo
  ---Type <return> to continue, or q <return> to quit---No unwaited-for children left.
  Couldn't get registers: No such process.
  Couldn't get registers: No such process.
  Couldn't get registers: No such process.
  (gdb) Couldn't get registers: No such process.
  (gdb)

To reiterate, the user hasn't replied to the pagination prompt above.

A pagination query nests an event loop (in gdb_readline_wrapper).  In
async mode, in addition to stdin and signal handlers, we'll have the
target also installed in the event loop still.  So if the target
reports an event, that wakes up the nested event loop, which calls
into fetch_inferior_event etc. to handle the event which generates
further output, all while we should be waiting for pagination
confirmation...

(TBC, any target event that generates output ends up spuriously waking
up the pagination, though exits seem to be the worse kind.)

I've played with a couple different approaches to fixing this, while
at the same time trying to avoid being invasive.  Both revolve around
not listening to target events while in a pagination prompt (doing
anything else I think would be a much bigger change).

The approach taken just removes the target from the event loop while
within gdb_readline_wrapper.  The other approach used gdb_select
directly, with only input_fd installed, but that had the issue that it
didn't handle the async signal handlers, and turned out to be a bit
more code than the first version.

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

	PR gdb/17072
	* top.c: Include "inf-loop.h".
	(struct gdb_readline_wrapper_cleanup) <target_is_async_orig>: New
	field.
	(gdb_readline_wrapper_cleanup): Make the target async again, if it
	was async before.
	(gdb_readline_wrapper): Store whether the target is async, and
	make it sync.

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

	PR gdb/17072
	* gdb.base/paginate-inferior-exit.c: New file.
	* gdb.base/paginate-inferior-exit.exp: New file.
2014-07-14 20:33:16 +01:00
Pedro Alves 0017922d02 Background execution + pagination aborts readline/gdb
If pagination occurs as result of output sent as response to a target
event while the target is executing in the background, subsequent
input aborts readline/gdb:

 $ gdb program
 ...
 (gdb) continue&
 Continuing.
 (gdb)
 ---Type <return> to continue, or q <return> to quit---
 *return*
 ---Type <return> to continue, or q <return> to quit---
 Breakpoint 2, after_sleep () at paginate-bg-execution.c:21
 ---Type <return> to continue, or q <return> to quit---
 21        return; /* after sleep */
 p 1
 readline: readline_callback_read_char() called with no handler!
 *abort/SIGABRT*
 $

gdb_readline_wrapper_line removes the handler after a line is
processed.  Usually, we'll end up re-displaying the prompt, and that
reinstalls the handler.  But if the output is coming out of handling
a stop event, we don't re-display the prompt, and nothing restores the
handler.  So the next input wakes up the event loop and calls into
readline, which aborts.

We should do better with the prompt handling while the target is
running (I think we should coordinate with readline, and
hide/redisplay it around output), but that's a more invasive change
better done post 7.8, so this patch is conservative and just
reinstalls the handler as soon as we're out of the readline line
callback.

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

	PR gdb/17072
	* top.c (gdb_readline_wrapper_line): Tweak comment.
	(gdb_readline_wrapper_cleanup): If readline is enabled, reinstall
	the input handler callback.

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

	PR gdb/17072
	* gdb.base/paginate-bg-execution.c: New file.
	* gdb.base/paginate-bg-execution.exp: New file.
2014-07-14 20:32:13 +01:00
Pedro Alves 94696ad31c Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:

 $ ./gdb program -ex "set height 2" -ex "start"
 ...
 Reading symbols from /home/pedro/gdb/tests/threads...done.
 ---Type <return> to continue, or q <return> to quit---^CQuit  << ctrl-c triggers a Quit

 *type something*
 readline: readline_callback_read_char() called with no handler!
 Aborted
 $

Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command.  That's done in the event loop's actual loop
(event-loop.c:start_event_loop).  However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.

When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop.  Any
input from here on results in readline aborting.

Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.

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

	PR gdb/17072
	* main.c: Include event-top.h.
	(handle_command_errors): New function.
	(catch_command_errors, catch_command_errors_const): Use it.

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

	PR gdb/17072
	* gdb.base/paginate-execution-startup.c: New file.
	* gdb.base/paginate-execution-startup.exp: New file.
	* lib/gdb.exp (pagination_prompt): New global.
	(default_gdb_spawn): New procedure, factored out from
	default_gdb_spawn.
	(default_gdb_start): Adjust to call default_gdb_spawn.
	(gdb_spawn): New procedure.
2014-07-14 20:31:04 +01:00
Pedro Alves bd29394088 testsuite: Introduce gdb_assert
Often we'll do something like:

    if {$ok} {
	fail "whatever"
    } else {
	pass "whatever"
    }

This adds a helper procedure for that, and converts one random place
to use it, as an example.

2014-07-14  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (gdb_assert): New procedure.
	* gdb.trace/backtrace.exp (gdb_backtrace_tdp_4): Use it.
2014-07-14 20:30:41 +01:00
Pedro Alves 9d1e69a214 Move catch_command_errors and catch_command_errors_const to main.c
We'll need to add error handling code to commands run before the event
loop starts (commands in .gdbinit, -ex commands, etc.).  Turns out
those are run through catch_command_errors, and, catch_command_errors
is used nowhere else.  Move it (and the _const variant) to main.c, so
that we can further specialize it freely.

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

	* exceptions.c (catch_command_errors, catch_command_errors_const):
	Moved to main.c.
	* exceptions.h (catch_command_errors_ftype)
	(catch_command_errors_const_ftype): Moved to main.c.
	(catch_command_errors, catch_command_errors_const): Delete
	declarations.
	* main.c (catch_command_errors_ftype)
	(catch_command_errors_const_ftype): Moved here from exceptions.h.
	(catch_command_errors, catch_command_errors_const)): Moved here
	from exceptions.c and make static.
2014-07-14 20:30:12 +01:00
Pedro Alves feefc97b59 Eliminate exceptions.c:print_any_exception.
exception_print and exception_fprintf call print_flush, which does all the
same flushing and annotation things that print_any_exception does, and more.

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

	* exceptions.c (print_any_exception): Delete.
	(catch_exceptions_with_msg): Use exception_print instead of
	print_any_exception.
	(catch_errors): Use exception_fprintf instead of
	print_any_exception.
	(catch_command_errors, catch_command_errors_const): Use
	exception_print instead of print_any_exception.
2014-07-14 20:29:30 +01:00
Pedro Alves c933f875f4 Put the inferior's terminal settings in effect while running (fg) infcalls
The "call" and "print" commands presently always run synchronously, in
the foreground, but GDB currently forgets to put the inferior's
terminal settings into effect while running them, on async-capable
targets, resulting in:

 (gdb) print func ()
 hello world

 Program received signal SIGTTOU, Stopped (tty output).
 0x000000373bceb8d0 in __libc_tcdrain (fd=1) at ../sysdeps/unix/sysv/linux/tcdrain.c:29
 29          return INLINE_SYSCALL (ioctl, 3, fd, TCSBRK, 1);
 The program being debugged was signaled while in a function called from GDB.
 GDB remains in the frame where the signal was received.
 To change this behavior use "set unwindonsignal on".
 Evaluation of the expression containing the function
 (func) will be abandoned.
 When the function is done executing, GDB will silently stop.
 (gdb)

That's because target_terminal_inferior skips actually doing anything
if running in the background, and, nothing is setting sync_execution
while running infcalls:

 void
 target_terminal_inferior (void)
 {
   /* A background resume (``run&'') should leave GDB in control of the
      terminal.  Use target_can_async_p, not target_is_async_p, since at
      this point the target is not async yet.  However, if sync_execution
      is not set, we know it will become async prior to resume.  */
   if (target_can_async_p () && !sync_execution)
     return;

This would best be all cleaned up by making GDB not even call
target_terminal_inferior and try to pass the terminal to the inferior
if running in the background, but that's a more invasive fix that is
better done post-7.8.

This was originally caught by a patch later in this series that makes
catch_command_errors use exception_print instead of
print_any_exception.  Note that print_flush calls serial_drain_output
while print_any_exception doesnt't have that bit.  And,
gdb.gdb/python-selftest.exp does:

 gdb_test "call catch_command_errors(execute_command, \"python print 5\", 0, RETURN_MASK_ALL)" \
   "Python not initialized.* = 0"

which without this fix results in SIGTTOU...

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

	* infcall.c (run_inferior_call): Set 'sync_execution' while
	running the inferior call.

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

	* gdb.base/execution-termios.c: New file.
	* gdb.base/execution-termios.exp: New file.
2014-07-14 19:55:30 +01:00
Pedro Alves feb6f816c2 Garbage collect value_contents_equal.
Hasn't been used in years.

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

	* value.c (value_contents_equal): Delete function.
	* value.h (value_contents_equal): Delete declaration.
2014-07-14 18:48:09 +01:00
Tom Tromey d98b7a16a9 fix PR 17106
This fixes PR 17106, a regression in printing.

The bug is that resolve_dynamic_type follows struct members and
references, but doesn't consider the possibility of infinite
recursion.

This patch fixes the problem by limiting reference following to the
topmost layer of calls -- that is, reference-typed struct members are
never considered as being VLAs.

Built and regtested on x86-64 Fedora 20.
New test case included.

2014-07-14  Tom Tromey  <tromey@redhat.com>

	PR exp/17106:
	* gdbtypes.c (is_dynamic_type_internal): New function, from
	is_dynamic_type.
	(is_dynamic_type): Rewrite.
	(resolve_dynamic_union): Use resolve_dynamic_type_internal.
	(resolve_dynamic_struct): Likewise.
	(resolve_dynamic_type_internal): New function, from
	resolve_dynamic_type.
	(resolve_dynamic_type): Rewrite.

2014-07-14  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/vla-cxx.cc: New file.
	* gdb.cp/vla-cxx.exp: New file.
2014-07-14 10:14:36 -06:00
Tom Tromey 548740d6bd fix record "run" regression
This fixes the record "run" regression pointed out by Marc Khouzam:

    https://sourceware.org/ml/gdb/2014-06/msg00096.html

The bug is that target_require_runnable must agree with the handling
of the "run" target, but currently it is out of sync.  This patch
fixes the problem by changing target_require_runnable to also ignore
the record_stratum.

Built and regtested on x86-64 Fedora 20.
New test case included.

2014-07-14  Tom Tromey  <tromey@redhat.com>

	* target.c (target_require_runnable): Also check record_stratum.
	Update comment.

2014-07-14  Tom Tromey  <tromey@redhat.com>

	* gdb.reverse/rerun-prec.c: New file.
	* gdb.reverse/rerun-prec.exp: New file.
2014-07-14 08:33:05 -06:00
Maciej W. Rozycki a25eb0280d gdb/testsuite: Add a way to send multiple init commands
Right now we provide a board info entry, `gdb_init_command', that allows
one to send a single command to GDB before the program to be debugged is
started.  This is useful e.g. for slow remote targets to change the
default "remotetimeout" setting.  Occasionally I found a need to send
multiple commands instead, however this cannot be achieved with
`gdb_init_command'.

This change therefore extends the mechanism by adding a TCL list of GDB
commands to send, via a board info entry called `gdb_init_commands'.
There is no limit as to the number of commands put there.  The old
`gdb_init_command' mechanism remains supported for compatibility with
existing people's environments.

	* lib/gdb-utils.exp: New file.
	* lib/gdb.exp (gdb_run_cmd): Call gdb_init_commands, replacing
	inline `gdb_init_command' processing.
	(gdb_start_cmd): Likewise.
	* lib/mi-support.exp (mi_run_cmd): Likewise.
	* README: Document `gdb_init_command' and `gdb_init_commands'.
2014-07-12 01:39:40 +01:00
Jan Kratochvil 218c265560 Fix false argv0-symlink.exp FAIL running under a very long directory name
Starting program: /home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff/gdb/testsuite/gdb.base/argv0-symlink-filelink ^M
[...]
(gdb) print argv[0]^M
$1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-", 'f' <repeats 169 times>...^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name

after "set print repeats 10000":

print argv[0]^M
$1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"...^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name

after "set print elements 10000":

print argv[0]^M
$1 = 0x7fffffffda39 "/home/jkratoch/redhat/gdb-test-fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff/gdb/testsuite/gdb.base/argv0-symlink-filelink"^M
(gdb) PASS: gdb.base/argv0-symlink.exp: kept file symbolic link name

gdb/testsuite/
2014-07-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix false FAIL running under a very long directory name.
	* gdb.base/argv0-symlink.exp: Add "set print repeats 10000"
	and "set print elements 10000".  Twice.
2014-07-11 17:26:42 +02:00
Yao Qi 808f7ab1fc Stop prologue analysis when past the epilogue
We see a fail in gdb.trace/entry-values.exp on armv4t thumb,

bt^M
 #0  0x000086fc in foo (i=0, i@entry=<optimized out>, j=2, j@entry=<optimized out>)^M
 #1  0x00000002 in ?? ()^M
Backtrace stopped: previous frame identical to this frame (corrupt stack?)^M
(gdb) FAIL: gdb.trace/entry-values.exp: bt (1) (pattern 1)

The fail is caused by incorrect prologue analysis, which can be illustrated by
setting a breakpoint on function foo,

(gdb) disassemble foo
Dump of assembler code for function foo:
   0x000086e8 <+0>:	push	{r7, lr}
   0x000086ea <+2>:	sub	sp, #8
   0x000086ec <+4>:	add	r7, sp, #0
   0x000086ee <+6>:	str	r0, [r7, #4]
   0x000086f0 <+8>:	str	r1, [r7, #0]
   0x000086f2 <+10>:	movs	r3, #0
   0x000086f4 <+12>:	adds	r0, r3, #0
   0x000086f6 <+14>:	mov	sp, r7
   0x000086f8 <+16>:	add	sp, #8
   0x000086fa <+18>:	pop	{r7}
   0x000086fc <+20>:	pop	{r1}
   0x000086fe <+22>:	bx	r1
End of assembler dump.
(gdb) b foo
Breakpoint 1 at 0x86fc

As we can see, GDB analyzes the prologue and skip the prologue to the last
instruction but one.  The breakpoint is set within the epilogue, and GDB
skips too many instruction for prologue.  This patch teaches GDB to stop
prologue analysis when goes into the epilogue.  With this patch applied,
GDB is able to unwind correctly,

(gdb) bt
 #0  0x000086f6 in foo (i=0, i@entry=2, j=2, j@entry=3)
 #1  0x00008718 in bar (i=<optimized out>)
 #2  0x00008758 in main ()

gdb:

2014-07-11  Yao Qi  <yao@codesourcery.com>

	* arm-tdep.c (thumb_analyze_prologue): Break the loop if
	thumb_instruction_restores_sp return true.
2014-07-11 21:34:01 +08:00
Yao Qi 540314bdd8 Match instruction adjusts SP in thumb
This is a refactor patch, that moves matching instructions adjusting
SP into a new function, thumb_instruction_restores_sp.  The second
call to thumb_instruction_restores_sp in thumb_in_function_epilogue_p
is a little different from the original.  The original code matches
'POP <registers> without PC', but thumb_in_function_epilogue_p matches
'POP <registers> (with and without PC)'.  However, GDB found one
instruction about return and is scanning the previous instruction,
which should be an instruction about return too, so the code change
doesn't affect the functionality.

gdb:

2014-07-11  Yao Qi  <yao@codesourcery.com>

	* arm-tdep.c (thumb_instruction_restores_sp): New function.
	(thumb_in_function_epilogue_p): Call
	thumb_instruction_restores_sp.
2014-07-11 21:33:55 +08:00
Yao Qi 1db01f22f5 Restrict matching add/sub sp, #imm
Currently, GDB matches both add/sub sp, #imm in prologue and epilogue,
which is not very precise.  On the instruction level, the immediate
number in both instruction can't be negative, so 'sub sp, #imm' only
appears in prologue while 'add sp, #imm' only appears in epilogue.
Note that on assembly level, we can write 'add sp, -8', but gas will
translate to 'sub sp, 8' instruction.

This patch is to only match 'sub sp, #imm' in prologue and match
'add sp, #immm' in epilogue.  It paves the way for the following
patch.

gdb:

2014-07-11  Yao Qi  <yao@codesourcery.com>

	* arm-tdep.c (thumb_analyze_prologue): Don't match instruction
	'add sp, #imm'.
	(thumb_in_function_epilogue_p): Don't match 'sub sp, #imm'.
2014-07-11 21:33:50 +08:00
Gary Benson 3116063bd6 Tidy #include lists
This commit tidies up the #include lists in {i386,amd64}-linux-nat.c,
removing headers that are no longer required and reordering some lines
so that both files roughly match.  Additionally, an unused definition
was removed from the middle of the #include list in i386-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (gdbcore.h): Remove include.
	(regset.h): Likewise.
	(nat/linux-btrace.h): Likewise.
	(btrace.h): Likewise.
	(gdb_assert.h): Likewise.
	(string.h): Likewise.
	(sys/uio.h): Likewise.
	(sys/debugreg.h): Likewise.
	(sys/syscall.h): Likewise.
	(sys/procfs.h): Likewise.
	(sys/user.h): Likewise.
	(asm/ptrace.h): Likewise.
	(i386-nat.h): Likewise.
	* i386-linux-nat.c (i386-nat.h): Likewise.
	(regset.h): Likewise.
	(target.h): Likewise.
	(linux-nat.h): Likewise.
	(nat/linux-btrace.h): Likewise.
	(btrace.h): Likewise.
	(gdb_assert.h): Likewise.
	(string.h): Likewise.
	(sys/uio.h): Likewise.
	(sys/user.h): Likewise.
	(sys/procfs.h): Likewise.
	(sys/reg.h): Likewise.
	(sys/debugreg.h): Likewise.
	(ORIG_EAX): Remove definition.
2014-07-11 12:24:28 +01:00
Gary Benson 040baaf6de Move duplicated code into new files
This commit moves the duplicated code in {i386,amd64}-linux-nat.c
into the new files x86-linux-nat.[ch].  Additionally, a new
file i386-linux-nat.h was required to expose a value required
by the 32-bit code in x86-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* i386-linux-nat.h: New file.
	* x86-linux-nat.h: Likewise.
	* x86-linux-nat.c: Likewise.
	* Makefile.in (HFILES_NO_SRCDIR): Add the above new headers.
	* config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o.
	* config/i386/linux64.mh (NATDEPFILES): Likewise.
	* amd64-linux-nat.c (x86-linux-nat.h): New include.
	(PTRACE_GETREGSET): Now in x86-linux-nat.h.
	(PTRACE_SETREGSET): Likewise.
	(arch_lwp_info): Now in x86-linux-nat.c.
	(have_ptrace_getregset): Now in x86-linux-nat.h.
	(x86_linux_dr_get): Now in x86-linux-nat.c.
	(x86_linux_dr_set): Likewise.
	(x86_linux_dr_get_addr): Likewise.
	(x86_linux_dr_get_control): Likewise.
	(x86_linux_dr_get_status): Likewise.
	(update_debug_registers_callback): Likewise.
	(x86_linux_dr_set_control): Likewise.
	(x86_linux_dr_set_addr): Likewise.
	(x86_linux_prepare_to_resume): Likewise.
	(x86_linux_new_thread): Likewise.
	(x86_linux_new_fork): Likewise.
	(x86_linux_get_thread_area): Likewise.
	(super_post_startup_inferior): Likewise.
	(x86_linux_child_post_startup_inferior): Likewise.
	(AMD64_LINUX_USER64_CS): Likewise.
	(AMD64_LINUX_X32_DS): Likewise.
	(x86_linux_read_description): Likewise.
	(x86_linux_enable_btrace): Likewise.
	(x86_linux_disable_btrace): Likewise.
	(x86_linux_teardown_btrace): Likewise.
	(x86_linux_read_btrace): Likewise.
	(x86_linux_create_target): Likewise.
	(x86_linux_add_target): Likewise.
	* i386-linux-nat.c (x86-linux-nat.h): New include.
	(PTRACE_GETREGSET): Now in x86-linux-nat.h.
	(PTRACE_SETREGSET): Likewise.
	(arch_lwp_info): Now in x86-linux-nat.c.
	(have_ptrace_getregset): Now in x86-linux-nat.h.
	(x86_linux_dr_get): Now in x86-linux-nat.c.
	(x86_linux_dr_set): Likewise.
	(x86_linux_dr_get_addr): Likewise.
	(x86_linux_dr_get_control): Likewise.
	(x86_linux_dr_get_status): Likewise.
	(update_debug_registers_callback): Likewise.
	(x86_linux_dr_set_control): Likewise.
	(x86_linux_dr_set_addr): Likewise.
	(x86_linux_prepare_to_resume): Likewise.
	(x86_linux_new_thread): Likewise.
	(x86_linux_new_fork): Likewise.
	(x86_linux_get_thread_area): Likewise.
	(super_post_startup_inferior): Likewise.
	(x86_linux_child_post_startup_inferior): Likewise.
	(AMD64_LINUX_USER64_CS): Likewise.
	(AMD64_LINUX_X32_DS): Likewise.
	(x86_linux_read_description): Likewise.
	(x86_linux_enable_btrace): Likewise.
	(x86_linux_disable_btrace): Likewise.
	(x86_linux_teardown_btrace): Likewise.
	(x86_linux_read_btrace): Likewise.
	(x86_linux_create_target): Likewise.
	(x86_linux_add_target): Likewise.
2014-07-11 12:24:26 +01:00
Gary Benson 1aa7e42c3f Comment and whitespace changes
This commit merges the comments and whitespace in the common
parts of i386-linux-nat.c and amd64-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c: Comment and whitespace changes.
	* i386-linux-nat.c: Comment and whitespace changes.
2014-07-11 12:24:22 +01:00
Gary Benson c1e246a060 Pull out common parts of _initialize_{i386,amd64}_linux_nat
This commit adds two new helpers, x86_linux_create_target and
x86_linux_add_target, to hold the parts of _initialize_i386_linux_nat
and _initialize_amd64_linux_nat which are common.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (x86_linux_create_target): New function.
	(x86_linux_add_target): Likewise.
	(_initialize_amd64_linux_nat): Delegate to the above new functions.
	* i386-linux-nat.c (x86_linux_create_target): New function.
	(x86_linux_add_target): Likewise.
	(_initialize_i386_linux_nat): Delegate to the above new functions.
2014-07-11 12:24:11 +01:00
Gary Benson 8c420b8d59 Merge ps_get_thread_area
This commit adds a new helper, x86_linux_get_thread_area, to
hold the common parts of the ps_get_thread_area functions in
i386-linux-nat.c and amd64-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (x86_linux_get_thread_area): New function.
	(ps_get_thread_area): Delegate to the above in 32-bit mode.
	* i386-linux-nat.c (x86_linux_get_thread_area): New function.
	(ps_get_thread_area): Delegate to the above.
2014-07-11 12:23:16 +01:00
Gary Benson cb1da100b6 Merge {i386,amd64}_linux_read_description
This commit merges i386_ and amd64_linux_read_description, renaming
both to x86_linux_read_description.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (amd64_linux_read_description): Renamed to
	x86_linux_read_description.  All uses updated.  amd64-specific
	code conditionalized.  Conditionalized i386-specific code added.
	Redundant cast removed.
	* i386-linux-nat.c (i386_linux_read_description): Renamed to
	x86_linux_read_description.  All uses updated.  i386-specific
	code conditionalized.  Conditionalized amd64-specific code added.
	One sizeof replaced with the actual type it is describing.
2014-07-11 12:23:15 +01:00
Gary Benson 2acf3cd065 Rename identical functions
amd64-linux-nat.c and i386-linux-nat.c contain a number of functions
which are identical but for prefix on their names.  This commit
renames all such functions to have the prefix x86_ instead of the
prefixes amd64_ or i386_ and updates all uses of those functions.
The now-identical x86_ functions will be pulled out to a separate
shared file in a later commit.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (amd64_linux_dr_get): Renamed to
	x86_linux_dr_get.  All uses updated.
	(amd64_linux_dr_set): Renamed to
	x86_linux_dr_set.  All uses updated.
	(amd64_linux_dr_get_addr): Renamed to
	x86_linux_dr_get_addr.  All uses updated.
	(amd64_linux_dr_get_control): Renamed to
	x86_linux_dr_get_control.  All uses updated.
	(amd64_linux_dr_get_status): Renamed to
	x86_linux_dr_get_status.  All uses updated.
	(amd64_linux_dr_set_control): Renamed to
	x86_linux_dr_set_control.  All uses updated.
	(amd64_linux_dr_set_addr): Renamed to
	x86_linux_dr_set_addr.  All uses updated.
	(amd64_linux_prepare_to_resume): Renamed to
	x86_linux_prepare_to_resume.  All uses updated.
	(amd64_linux_new_thread): Renamed to
	x86_linux_new_thread.  All uses updated.
	(amd64_linux_new_fork): Renamed to
	x86_linux_new_fork.  All uses updated.
	(amd64_linux_child_post_startup_inferior): Renamed to
	x86_linux_child_post_startup_inferior.  All uses updated.
	(amd64_linux_enable_btrace): Renamed to
	x86_linux_enable_btrace.  All uses updated.
	(amd64_linux_disable_btrace): Renamed to
	x86_linux_disable_btrace.  All uses updated.
	(amd64_linux_teardown_btrace): Renamed to
	x86_linux_teardown_btrace.  All uses updated.
	(amd64_linux_read_btrace): Renamed to
	x86_linux_read_btrace.  All uses updated.
	* i386-linux-nat.c (i386_linux_dr_get): Renamed to
	x86_linux_dr_get.  All uses updated.
	(i386_linux_dr_set): Renamed to
	x86_linux_dr_set.  All uses updated.
	(i386_linux_dr_get_addr): Renamed to
	x86_linux_dr_get_addr.  All uses updated.
	(i386_linux_dr_get_control): Renamed to
	x86_linux_dr_get_control.  All uses updated.
	(i386_linux_dr_get_status): Renamed to
	x86_linux_dr_get_status.  All uses updated.
	(i386_linux_dr_set_control): Renamed to
	x86_linux_dr_set_control.  All uses updated.
	(i386_linux_dr_set_addr): Renamed to
	x86_linux_dr_set_addr.  All uses updated.
	(i386_linux_prepare_to_resume): Renamed to
	x86_linux_prepare_to_resume.  All uses updated.
	(i386_linux_new_thread): Renamed to
	x86_linux_new_thread.  All uses updated.
	(i386_linux_new_fork): Renamed to
	x86_linux_new_fork.  All uses updated.
	(i386_linux_child_post_startup_inferior): Renamed to
	x86_linux_child_post_startup_inferior.  All uses updated.
	(i386_linux_enable_btrace): Renamed to
	x86_linux_enable_btrace.  All uses updated.
	(i386_linux_disable_btrace): Renamed to
	x86_linux_disable_btrace.  All uses updated.
	(i386_linux_teardown_btrace): Renamed to
	x86_linux_teardown_btrace.  All uses updated.
	(i386_linux_read_btrace): Renamed to
	x86_linux_read_btrace.  All uses updated.
2014-07-11 12:23:14 +01:00
Yao Qi 5401fde353 Don't print symbol on address 0x0
We see the following fails on arm-none-eabi target,

print (void*)v_signed_char^M
$190 = (void *) 0x0 <_ftext>^M
(gdb) FAIL: gdb.base/exprs.exp: print (void*)v_signed_char (print
(void*)v_signed_char)

GDB behaves correctly but the test assumes there is no symbol on
address 0x0.  This patch is set print symbol off, so that tests below
can match the address only.

gdb/testsuite:

2014-07-11  Yao Qi  <yao@codesourcery.com>

	* gdb.base/exprs.exp: "set print symbol off".
2014-07-11 19:05:50 +08:00
Pedro Alves e76126e8d1 GDBserver crashes when killing a multi-thread process
Here's an example, with the new test:

 gdbserver :9999 gdb.threads/kill
 gdb gdb.threads/kill
 (gdb) b 52
 Breakpoint 1 at 0x4007f4: file kill.c, line 52.
 Continuing.

 Breakpoint 1, main () at kill.c:52
 52        return 0; /* set break here */
 (gdb) k
 Kill the program being debugged? (y or n) y

 gdbserver :9999 gdb.threads/kill
 Process gdb.base/watch_thread_num created; pid = 9719
 Listening on port 1234
 Remote debugging from host 127.0.0.1
 Killing all inferiors
 Segmentation fault (core dumped)

Backtrace:

 (gdb) bt
 #0  0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199
 #1  0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966
 #2  0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163
 #3  0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934
 #4  0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57
 #5  0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767
 #6  0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880
 #7  0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434
 #8  0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189
 #9  0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552
 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283

The problem is that linux_wait_for_event deletes lwps that have exited
(even those not passed in as lwps of interest), while the lwp/thread
list is being walked on with find_inferior.  find_inferior can handle
the current iterated inferior being deleted, but not others.

When killing lwps, we don't really care about any of the pending
status handling of linux_wait_for_event.  We can just waitpid the lwps
directly, which is also what GDB does (see
linux-nat.c:kill_wait_callback).  This way the lwps are not deleted
while we're walking the list.  They'll be deleted by linux_mourn
afterwards.

This crash triggers several times when running the testsuite against
GDBserver with the native-gdbserver board (target remote), but as GDB
can't distinguish between GDBserver crashing and "kill" being
sucessful, as in both cases the connection is closed (the 'k' packet
doesn't require a reply), and the inferior is gone, that results in no
FAIL.

The patch adds a generic test that catches the issue with
extended-remote mode (and works fine with native testing too).  Here's
how it fails with the native-extended-gdbserver board without the fix:

 (gdb) info threads
   Id   Target Id         Frame
   6    Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   5    Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   4    Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   3    Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   2    Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
 * 1    Thread 15367.15367 main () at .../gdb.threads/kill.c:52
 (gdb) kill
 Kill the program being debugged? (y or n) y
 Remote connection closed
 ^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) FAIL: gdb.threads/kill.exp: kill

Extended remote should remain connected after the kill.

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

	* linux-low.c (kill_wait_lwp): New function, based on
	kill_one_lwp_callback, but use my_waitpid directly.
	(kill_one_lwp_callback, linux_kill): Use it.

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

	* gdb.threads/kill.c: New file.
	* gdb.threads/kill.exp: New file.
2014-07-11 11:07:13 +01:00
Adrian Sendroiu b9c1d481cc remote: call remote_check_symbols after attaching
When debugging a remote bare-metal target with "target
extended-remote" + attach, GDB won't send a qSymbol packet to initiate
symbol lookup.  This happens because all the previous places in which
GDB might have done this are guarded by conditions that don't hold in
the said scenario: there are no shared libraries, no vsyscall page and
the binary file didn't change in the time passed between the "file"
and the "attach" commands.

To solve this problem remote_check_symbols is called in the
target_post_attach hook.

gdb/
2014-07-11  Adrian Sendroiu  <adrian.sendroiu@freescale.com>

	* remote.c (extended_remote_post_attach): New function.
	(init_extended_remote_ops): Install it as to_post_attach method.
2014-07-11 10:51:48 +01:00
Doug Evans e86c23a851 Revert gdbthread.h (any_running): Declare.
Not properly marked as 1/2.
This reverts commit 1a76d59888.
2014-07-10 12:30:05 -07:00
Doug Evans 1a76d59888 * gdbthread.h (any_running): Declare.
* thread.c (any_running): New function.
2014-07-10 11:15:32 -07:00
Yao Qi 2d6f0de676 Tweak gdb.trace/tfile.c for thumb mode
We see the fail below happens on thumb related multi-libs
(-mthumb -march={armv4t,armv7-a}),

target tfile tfile-basic.tf ^M
warning: Uploaded tracepoint 1 has no source location, using raw address^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
Tracepoint 3 at 0x8958: file /scratch/yqi/arm-none-linux-gnueabi/src/gdb-trunk/gdb/testsuite/gdb.trace/tfile.c, line 91.^M
Created tracepoint 3 for target's tracepoint 1 at 0x8959.^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
warning: Breakpoint address adjusted from 0x00008959 to 0x00008958.^M
(gdb) FAIL: gdb.trace/tfile.exp: complete-command 'target tfile'

The address of write_basic_trace_file is two-bytes aligned,

(gdb) p write_basic_trace_file
$1 = {void (void)} 0x8958 <write_basic_trace_file>

but the ld sets the LSB of every reference to the function address
(indicating the address is in thumb mode), so "&write_basic_trace_file"
in the program becomes 0x8959, which is saved in the trace file.  That
is why the warnnings are emitted.

This patch is to clear the LSB of the function address written to trace
file in thumb and thumb2 mode.  This patch fixes the fail above.

gdb/testsuite:

2014-07-10  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/tfile.c (write_basic_trace_file)
	[__thumb__||__thumb2__]: Clear the Thumb bit of the function
	address written to trace file.
2014-07-10 09:02:01 +08:00
Pedro Alves 7180e04a36 Fix "attach" command vs user input race
On async targets, a synchronous attach is done like this:

   #1 - target_attach is called (PTRACE_ATTACH is issued)
   #2 - a continuation is installed
   #3 - we go back to the event loop
   #4 - target reports stop (SIGSTOP), event loop wakes up, and
        attach continuation is called
   #5 - among other things, the continuation calls
        target_terminal_inferior, which removes stdin from the event
        loop

Note that in #3, GDB is still processing user input.  If the user is
fast enough, e.g., with something like:

  echo -e "attach PID\nset xxx=1" | gdb

... then the "set" command is processed before the attach completes.

We get worse behavior even, if input is a tty and therefore
readline/editing is enabled, with e.g.,:

 (gdb) attach PID\nset xxx=1

we then crash readline/gdb, with:

 Attaching to program: attach-wait-input, process 14537
 readline: readline_callback_read_char() called with no handler!
 Aborted
 $

Fix this by calling target_terminal_inferior before #3 above.

The test covers both scenarios by running with editing/readline forced
to both on and off.

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

	* infcmd.c (attach_command_post_wait): Don't call
	target_terminal_inferior here.
	(attach_command): Call it here instead.

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

	* gdb.base/attach-wait-input.exp: New file.
	* gdb.base/attach-wait-input.c: New file.
2014-07-09 15:59:02 +01:00
Andrew Burgess 9a9a760829 Improve MI -var-info-path-expression for nested struct/union case.
https://sourceware.org/ml/gdb-patches/2014-05/msg00383.html

The MI command -var-info-path-expression currently does not handle
non-anonymous structs / unions nested within other structs / unions,
it will skip parts of the expression.  Consider this example:

  ## START EXAMPLE ##
  $ cat ex.c
  #include <string.h>

  int
  main ()
  {
    struct s1
    {
      int a;
    };

    struct ss
    {
      struct s1 x;
    };

    struct ss an_ss;
    memset (&an_ss, 0, sizeof (an_ss));
    return 0;
  }
  $ gcc -g -o ex.x ex.c
  $ gdb ex.x
  (gdb) break 18
  Breakpoint 1 at 0x80483ba: file ex.c, line 18.
  (gdb) run
  Starting program: /home/user/ex.x

  Breakpoint 1, main () at ex.c:18
  18	  return 0;
  (gdb) interpreter-exec mi "-var-create an_ss * an_ss"
  (gdb) interpreter-exec mi "-var-list-children an_ss"
  ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x"
  ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x.a"
  ^done,numchild="0",has_more="0"
  (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a"
  ^done,path_expr="(an_ss).a"
  (gdb) print (an_ss).a
  There is no member named a.
  ## END EXAMPLE ##

Notice that the path expression returned is wrong, and as a result
the print command fails.

This patch adds a new method to the varobj_ops structure called
is_path_expr_parent, to allow language specific control over finding
the parent varobj, the current logic becomes the C/C++ version and is
extended to handle the nested cases.  No other language currently uses
this code, so all other languages just get a default method.

With this patch, the above example now finishes like this:

  ## START EXAMPLE ##
  $ gdb ex.x
  (gdb) break 18
  Breakpoint 1 at 0x80483ba: file ex.c, line 18.
  (gdb) run
  Starting program: /home/user/ex.x

  Breakpoint 1, main () at ex.c:18
  18	  return 0;
  (gdb) interpreter-exec mi "-var-list-children an_ss"
  ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x"
  ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0"
  (gdb) interpreter-exec mi "-var-list-children an_ss.x.a"
  ^done,numchild="0",has_more="0"
  (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a"
  ^done,path_expr="((an_ss).x).a"
  (gdb) print ((an_ss).x).a
  $1 = 0
  ## END EXAMPLE ##

Notice that the path expression is now correct, and the print is a
success.

gdb/ChangeLog:

	* ada-varobj.c (ada_varobj_ops): Fill in is_path_expr_parent
	field.
	* c-varobj.c (c_is_path_expr_parent): New function, moved core
	from varobj.c, with additional checks.
	(c_varobj_ops): Fill in is_path_expr_parent field.
	(cplus_varobj_ops): Fill in is_path_expr_parent field.
	* jv-varobj.c (java_varobj_ops): Fill in is_path_expr_parent
	field.
	* varobj.c (is_path_expr_parent): Call is_path_expr_parent varobj
	ops method.
	(varobj_default_is_path_expr_parent): New function.
	* varobj.h (lang_varobj_ops): Add is_path_expr_parent field.
	(varobj_default_is_path_expr_parent): Declare new function.

gdb/testsuite/ChangeLog:

	* gdb.mi/var-cmd.c (do_nested_struct_union_tests): New function
	setting up test structures.
	(main): Call new test function.
	* gdb.mi/mi2-var-child.exp: Create additional breakpoint in new
	test function, continue into test function and walk test
	structures.
2014-07-09 14:47:47 +01:00
Yao Qi 161ac41e03 Fix gdb.trace/entry-values.exp for thumb mode
We see some fails in gdb.trace/entry-values.exp in thumb mode
(-mthumb -march={armv4t,armv7-a}).

In thumb mode, the lsb of references to 'foo' and 'bar' in the assembly
(produced by dwarf assember) is set, so the generated debug
information is incorrect.

This patch copies the approach used by

  [PATCH 4/4] Fix dw2-ifort-parameter.exp on PPC64
  https://sourceware.org/ml/gdb-patches/2014-03/msg00202.html

to introduce new labels 'foo_start' and 'bar_start' which are about
the correct function address (without lsb set).  This patch fixes
these fails we've seen.

gdb/testsuite:

2014-07-08  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/entry-values.c: Define labels 'foo_start' and
	'bar_start' at the beginning of functions 'foo' and 'bar'
	respectively.
	* gdb.trace/entry-values.exp: Use 'foo_start' and 'bar_start'
	instead of 'foo' and 'bar'.
2014-07-08 16:48:22 +08:00
Markus Metzger 1f267ae3d1 reverse-finish: turn internal error into normal error
The reverse-finish command results in an internal error if it cannot determine
the current function.

  (gdb) c
  Continuing.

  Program received signal SIGSEGV, Segmentation fault.
  0x0000000000000000 in ?? ()
  (gdb) reverse-finish
  Run back to call of #0  0x0000000000000000 in ?? ()
  gdb/infcmd.c:1576: internal-error: Finish: couldn't find function.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) y

This is not an internal error case since the command may be used in scenarios
where there is no function at the current PC, e.g. after calling through a bad
function pointer.

Turn this into a normal error.

gdb/
	* infcmd.c (finish_backward): Turn internal error into normal error.

testsuite/
	* gdb.btrace/segv.c: New.
	* gdb.btrace/segv.exp: New.
2014-07-08 10:07:59 +02:00
Pedro Alves 8a869bcaa5 Mention PR gdb/17096 in ChangeLog 2014-07-07 19:05:05 +01:00
Pedro Alves b2ee242b93 PR gdb/17096: async support breaks remote debugging on Windows
On Windows, with "maint set target-async on" (the default since
a09dd441), Ctrl-C fails to stop a remote target.

With maint target-async on, the SIGINT signal handler doesn't send the
remote interrupt request immediately.  Instead, it marks an async
handler as ready, and then the main event loop wakes up and notices
that the SIGINT async signal handler token was set, and calls the
corresponding event handler, which sends the remote interrupt request.

On POSIX-like systems, the SIGINT signal makes the select/poll in the
main event loop wake up / return with EINTR.  However, on Windows,
signal handlers run on a separate thread, and Windows doesn't really
have a concept of EINTR.  So, just marking the async handler
(effectively just setting a flag) does not wake up gdb_select.
Instead, we need to call gdb_call_async_signal_handler from the signal
handler.  The Windows version (in mingw-hdep.c) sets a Windows event
that gdb_select's WaitForMultipleObjects is waiting for.

Confirmed that with this, Ctrl-C interrupts the remote target on
Windows.  Also regression tested on x86_64 Fedora 20 against
GDBserver.

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

	* remote.c (async_handle_remote_sigint)
	(async_handle_remote_sigint_twice): Call
	gdb_call_async_signal_handler instead of
	mark_async_signal_handler.
2014-07-07 17:51:04 +01:00
Tom Tromey 38e229b2b3 change to_info_record to use target delegation
This changes to_info_record to use target delegation.
Also, target_info_record was unused, so this patch removes it.

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

	* target-delegates.c: Rebuild.
	* target.c (target_info_record): Remove.
	* record.c (info_record_command): Unconditionally call
	to_info_record.
	* target.h (struct target_ops) <to_info_record>: Use
	TARGET_DEFAULT_IGNORE.
	(target_info_record): Remove.
2014-07-07 09:06:15 -06:00
Tom Tromey f0f9ff9530 convert to_get_thread_local_address to use target delegation
This converts to_get_thread_local_address to use
TARGET_DEFAULT_NORETURN.  One possible oddity is that this changes the
text of the kind of exception thrown in some cases.  This doesn't seem
to be a problem; in fact perhaps the final call to 'error' in
target_translate_tls_address should be changed to call
generic_tls_error.

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

	* target.h (struct target_ops) <to_get_thread_local_address>: Use
	TARGET_DEFAULT_NORETURN.
	* target.c (generic_tls_error): New function.
	(target_translate_tls_address): Don't search target stack.
	* target-delegates.c: Rebuild.
	* ppc-linux-tdep.c (ppc_linux_spe_context): Don't search target
	stack.
	* linux-thread-db.c (thread_db_get_thread_local_address):
	Unconditionally call beneath target.
2014-07-07 09:06:14 -06:00
Marc Khouzam 4a5be5ee68 Assign 'targerr' instead of 'targ' to gdb_stdtargerr. 2014-07-03 14:57:33 -04:00
Andrew Burgess 92c3b204c7 Update email address in MAINTAINERS list. 2014-07-03 14:29:25 +01:00
Luis Machado 2b239efbec This testcase currently does not handle powerpc branches. It kinda
does in a way, because the arm/aarch64 branch instruction is the
same as powerpc's, but the target triplet pattern is not there.

In summary, the testcase fails to locate the branch offset and causes
a failure and the early termination of the test.

The following patch adds a separate conditional block for powerpc (to keep
things organized), allowing the testcase to continue.

2014-07-02  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.trace/entry-values.exp: Handle powerpc-specific branch
	instruction.
2014-07-02 11:59:02 +01:00
Gary Benson 9b11e3a732 Remove unused Linux libthread_db callbacks
gdb/proc-service.c includes several libthread_db callbacks that do not
exist in gdb/gdbserver/proc-service.c.  Other than in proc_service.h,
there is no reference to any of these callbacks in any revision of
nptl_db or linuxthreads_db in glibc's git repo so it seems likely that
these functions have never been called.  This commit removes them.

gdb/
2014-07-02  Gary Benson  <gbenson@redhat.com>

	* proc-service.c (ps_xfer_memory): Update comment.
	(ps_pstop): Remove unused function.
	(ps_pcontinue): Likewise.
	(ps_lstop): Likewise.
	(ps_lcontinue): Likewise.
	(ps_lgetxregsize): Likewise.
	(ps_lgetxregs): Likewise.
	(ps_lsetxregs): Likewise.
	(ps_plog): Likewise.
	(ps_ptread): Likewise.
	(ps_ptwrite): Likewise.
2014-07-02 08:58:42 +01:00
Mark Wielaard cf363f183d Handle volatile array types in dwarf2read.c.
read_tag_const_type propagates the cv-qualifier to the array element type,
but read_tag_volatile_type didn't. Make sure that both cv-qualifiers that
apply to array types are handled the same.

gdb/ChangeLog

	* dwarf2read.c (add_array_cv_type): New function.
	(read_tag_const_type): Call add_array_cv_type for TYPE_CODE_ARRAY.
	(read_tag_volatile_type): Likewise.

gdb/testsuite/ChangeLog

	* gdb.base/constvars.c (violent, violet, vips, virgen, vulgar,
	vulture, vilify, villar): New volatile array constants.
	(vindictive, vegetation): New const volatile array constants.
	* gdb.base/volatile.exp: Test volatile and const volatile array
	types.
2014-07-01 22:11:53 +02:00
Tom Tromey 82ae6c8d79 use cmd_sfunc_ftype and cmd_cfunc_ftype more
This patch changes a few more spots to use either cmd_sfunc_ftype or
cmd_cfunc_ftype, as appropriate.  This is a bit cleaner.

Tested by rebuilding.

2014-07-01  Tom Tromey  <tromey@redhat.com>

	* breakpoint.c (add_catch_command): Use cmd_sfunc_ftype.
	* breakpoint.h (add_catch_command): Use cmd_sfunc_ftype.
	* cli/cli-decode.c (cmd_cfunc_eq, add_cmd, add_prefix_cmd)
	(add_abbrev_prefix_cmd, add_info, add_com): Use cmd_cfunc_ftype.
	* command.h (cmd_cfunc_ftype): Move earlier.
	(add_cmd, add_prefix_cmd, add_abbrev_prefix_cmd, cmd_cfunc_eq)
	(add_com, add_info): Use cmd_cfunc_ftype.
2014-07-01 10:21:10 -06:00
Michael Eager 422b1cb091 2014-01-07 Michael Eager <eager@eagercon.com>
* dwarf2read.c (read_structure_type): Set stub if ICC & length == 0.
2014-06-30 17:40:01 -07:00
Tom Tromey 961427268a constify search_symbols
This constifies the parameters to search_symbols and fixes up the
fallout.

Tested by rebuilding.

2014-06-30  Tom Tromey  <tromey@redhat.com>

	* symtab.c (operator_chars): Make parameters and return type
	const.
	(file_matches): Make "files" const.
	(struct search_symbols_data) <files>: Now const.
	(search_symbols): Make "regexp" and "files" parameters const.
	Update.
	(symtab_symbol_info): Remove cast.
	(rbreak_command): Update.
	* symtab.h (search_symbols): Update.
2014-06-30 07:59:38 -06:00
Andreas Arnez aebf9d247e watchpoint-reuse-slot.exp: Correctly skip unsupported commands.
The test case "watchpoint-reuse-slot.exp" yields a lot of failures on
s390/s390x: all instances of awatch, rwatch, and hbreak are performed
even though they aren't supported on these targets.  This is because
the test case ignores non-support error messages when probing for
support of these commands, like:

    (gdb) rwatch buf.byte[0]
    Target does not support this type of hardware watchpoint.

The patch adds handling for this case in the appropriate
gdb_test_multiple invocations.

gdb/testsuite/
	* gdb.base/watchpoint-reuse-slot.exp: Handle the case that the
	target lacks support for awatch, rwatch, or hbreak.
2014-06-30 13:33:48 +02:00
Yao Qi b67a2c6fd4 Associate dummy_frame with ptid
This patch is to add ptid into dummy_frame and extend frame_id to
dummy_frame_id (which has a ptid field).  With this change, GDB uses
dummy_frame_id (thread ptid and frame_id) to find the dummy frames.

Currently, dummy frames are looked up by frame_id, which isn't
accurate in non-stop or multi-process mode.  The test case
gdb.multi/dummy-frame-restore.exp shows the problem and this patch can
fix it.

Test dummy-frame-restore.exp makes two inferiors stop at
different functions, say, inferior 1 stops at f1 while inferior 2
stops at f2.  Set a breakpoint to a function, do the inferior call
in two inferiors, and GDB has two dummy frames of the same frame_id.
When the inferior call is finished, GDB will look up a dummy frame
from its stack/list and restore the inferior's regcache.  Two
inferiors are finished in different orders, the inferiors' states are
restored differently, which is wrong.  Running dummy-frame-restore.exp
under un-patched GDB, we'll get two fails:

FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 2
FAIL: gdb.multi/dummy-frame-restore.exp: inf 2 first: after infcall: bt in inferior 1

With this patch applied, GDB will choose the correct dummy_frame to
restore for a given inferior, because ptid is considered when looking up
dummy frames.  Two fails above are fixed.

Regression tested on x86_64-linux, both native and gdbserver.

gdb:

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

	* breakpoint.c (check_longjmp_breakpoint_for_call_dummy):
	Change parameter type to 'struct thread_info *'.  Caller
	updated.
	* breakpoint.h (check_longjmp_breakpoint_for_call_dummy):
	Update declaration.
	* dummy-frame.c (struct dummy_frame_id): New.
	(dummy_frame_id_eq): New function.
	(struct dummy_frame) <id>: Change its type to 'struct
	dummy_frame_id'.
	(dummy_frame_push): Add parameter ptid and save it in
	dummy_frame_id.
	(pop_dummy_frame_bpt): Use ptid of dummy_frame instead of
	inferior_ptid.
	(pop_dummy_frame): Assert that the ptid of dummy_frame equals
	to inferior_ptid.
	(lookup_dummy_frame): Change parameter type to 'struct
	dummy_frame_id *'.  Callers updated.  Call dummy_frame_id_eq
	instead of frame_id_eq.
	(dummy_frame_pop): Add parameter ptid.  Callers updated.
	Update comments.  Compose dummy_frame_id and pass it to
	lookup_dummy_frame.
	(dummy_frame_discard): Add parameter ptid.
	(dummy_frame_sniffer): Compose dummy_frame_id and call
	dummy_frame_id_eq instead of frame_id_eq.
	(fprint_dummy_frames): Print ptid.
	* dummy-frame.h: Remove comments.
	(dummy_frame_push): Add ptid in declaration.
	(dummy_frame_pop, dummy_frame_discard): Likewise.

gdb/testsuite:

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

	* gdb.multi/dummy-frame-restore.exp: New.
	* gdb.multi/dummy-frame-restore.c: New.

gdb/doc:

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

	* gdb.texinfo (Maintenance Commands): Update the output of
	'maint print dummy-frames' command.
2014-06-27 20:06:56 +08:00
Tom Tromey 5b10184c58 constify error_no_arg
This is a trivial patch to make error_no_arg take a const argument.

2014-06-26  Tom Tromey  <tromey@redhat.com>

	* cli/cli-cmds.c (error_no_arg): Make "why" const.
	* command.h (error_no_arg): Update.
2014-06-26 09:14:18 -06:00
Tom Tromey 069003265c constify do_set_command and do_show_command
This changes do_set_command and do_show_command to take const
arguments.

2014-06-26  Tom Tromey  <tromey@redhat.com>

	* cli/cli-setshow.c (do_set_command): Make "arg" const.
	(do_show_command): Make "arg" const.
	* cli/cli-setshow.h (do_set_command, do_show_command): Update.
2014-06-26 09:14:17 -06:00
Tom Tromey c2bcbb1d04 constify get_bookmark and goto_bookmark
This makes arguments to to_get_bookmark and to_goto_bookmark const and
fixes the fallout.  Tested by rebuilding.  The only thing of note is
the new split between cmd_record_goto and record_goto -- basically
separating the CLI function from a new internal API, to allow const
propagation.

2014-06-26  Tom Tromey  <tromey@redhat.com>

	* record-full.c (record_full_get_bookmark): Make "args" const.
	(record_full_goto_bookmark): Make "raw_bookmark" const.
	* record.c (record_goto): New function.
	(cmd_record_goto): Use it.  Now static.
	* record.h (record_goto): Declare.
	(cmd_record_goto): Remove declaration.
	* target-delegates.c: Rebuild.
	* target.h (struct target_ops) <to_get_bookmark,
	to_goto_bookmark>: Make parameter const.
2014-06-26 09:14:16 -06:00
Tom Tromey 9cbe5fff2b constify to_load
This makes the argument to the target_ops to_load method "const", and
fixes up the fallout.  Tested by rebuilding all the affected files.

2014-06-26  Tom Tromey  <tromey@redhat.com>

	* defs.h (generic_load): Update.
	* m32r-rom.c (m32r_load_gen): Make "filename" const.
	* monitor.c (monitor_load): Make "args" const.
	* remote-m32r-sdi.c (m32r_load): Make "args" const.
	* remote-mips.c (mips_load_srec, pmon_load_fast): Make "args"
	const.
	(mips_load): Make "file" const.
	* remote-sim.c (gdbsim_load): Make "args" const.
	* remote.c (remote_load): Make "name" const.
	* symfile.c (generic_load): Make "args" const.
	* target-delegates.c: Rebuild.
	* target.c (target_load): Make "arg" const.
	(debug_to_load): Make "args" const.
	* target.h (struct target_ops) <to_load>: Make parameter const.
	(target_load): Update.
2014-06-26 09:14:14 -06:00
Tom Tromey 34a68019cc fix memory errors with demangled name hash
This fixes a regression that Jan pointed out.

The bug is that some names were allocated by dwarf2read on the objfile
obstack, but then passed to SYMBOL_SET_NAMES with copy_name=0.  This
violates the invariant that the names must have a lifetime tied to the
lifetime of the BFD.

The fix is to allocate names on the per-BFD obstack.

I looked at all callers, direct or indirect, of SYMBOL_SET_NAMES that
pass copy_name=0.  Note that only the ELF and DWARF readers do this;
other symbol readers were never updated (and perhaps cannot be,
depending on the details of the formats).  This is why the patch is
relatively small.

Built and regtested on x86-64 Fedora 20.

2014-06-26  Tom Tromey  <tromey@redhat.com>

	PR symtab/16902:
	* dwarf2read.c (fixup_go_packaging, dwarf2_compute_name)
	(dwarf2_physname, read_partial_die)
	(guess_partial_die_structure_name, fixup_partial_die)
	(guess_full_die_structure_name, anonymous_struct_prefix)
	(dwarf2_name): Use per-BFD obstack.
2014-06-26 08:11:04 -06:00
Yao Qi efc889c1a8 Move local variables to inner block
dummy_frame_sniffer has two local variables dummyframe and this_id,
but they are only used in the if block below.  This patch is to move
them into the inner block.

gdb:

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

	* dummy-frame.c (dummy_frame_sniffer): Move local variables
	dummyframe and this_id into inner block below.
2014-06-26 16:26:01 +08:00
Yao Qi 4395285e33 Typo fix in signal_pass initialization
When I read the code, I happen to see this:

   signal_pass = (unsigned char *)
     xmalloc (sizeof (signal_program[0]) * numsigs);
                      ^^^^^^^^^^^^^^
It is a typo, and this patch is to fix it.

gdb:

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

	* infrun.c (_initialize_infrun): Replace "signal_program[0]"
	with "signal_pass[0]" in the initialization of signal_pass.
2014-06-26 16:00:17 +08:00
Markus Metzger aef929023e btrace: pretend we're not replaying when generating a core file
When generating a core file using the "generate-core-file" command while
replaying with the btrace record target, we won't be able to access all
registers and all memory.  This leads to the following assertion:

    gdb/regcache.c:1034: internal-error: regcache_raw_supply: Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n) FAIL: gdb.btrace/gcore.exp: generate-core-file core (GDB internal error)
    Resyncing due to internal error.

Pretend that we are not replaying while generating a core file.  This will
forward fetch and store registers as well as xfer memory calls to the target
beneath.

gdb/
	* record-btrace.c (record_btrace_generating_corefile)
	(record_btrace_prepare_to_generate_core)
	(record_btrace_done_generating_core): New.
	(record_btrace_xfer_partial, record_btrace_fetch_registers)
	(record_btrace_store_registers, record_btrace_prepare_to_store):
	Forward request when generating a core file.
	(record_btrace_open): Set record_btrace_generating_corefile to zero.
	(init_record_btrace_ops): Set to_prepare_to_generate_core and
	to_done_generating_core.

testsuite/
	* gdb.btrace/gcore.exp: New.
2014-06-25 09:59:08 +02:00
Markus Metzger 5fff78c4e0 gcore, target: allow target to prepare/cleanup for/after core file generation
Add new target functions to_prepare_to_generate_core and
to_done_generating_core that are called before and after generating a core
file, respectively.

This allows targets to prepare for core file generation and to clean up
afterwards.

gdb/
	* target.h (target_ops) <to_prepare_to_generate_core>
	<to_done_generating_core>: New.
	(target_prepare_to_generate_core, target_done_generating_core): New.
	* target.c (target_prepare_to_generate_core)
	(target_done_generating_core): New.
	* target-delegates.c: Regenerate.
	* gcore.c: (write_gcore_file): Rename to ...
	(write_gcore_file_1): ...this.
	(write_gcore_file): Call target_prepare_to_generate_core
	and target_done_generating_core.
2014-06-25 09:57:16 +02:00
Markus Metzger 1d1f1ccb33 make_corefile_notes: have caller free returned memory
The various make_corefile_notes implementations for gdbarch as well as target
currently make an xfree cleanup on the data they return.  This causes problems
when trying to put a TRY_CATCH around the make_corefile_notes call.
Specifically, we get a stale cleanup error in restore_my_cleanups.

Omit the make_cleanup and have the caller free the memory.

gdb/
	* fbsd-nat.c (fbsd_make_corefile_notes): Remove make_cleanup call.
	* gcore.c (write_gcore_file): Free memory returned from
	make_corefile_notes.
	* linux-tdep.c (linux_make_corefile_notes): Remove make_cleanup call.
	* procfs.c (procfs_make_note_section): Remove make_cleanup call.
2014-06-25 09:54:31 +02:00
Eli Zaretskii f179cf97a0 Minor improvements in manual indexing.
* doc/gdb.texinfo (Screen Size): Add more index entries.
2014-06-24 19:28:40 +03:00
Yao Qi 3343ef8687 Skip 'bx reg' on arm-linux
In arm-tdep.c, arm_skip_stub is installed to gdbarch
skip_trampoline_code, but in arm-linux-tdep.c,
find_solib_trampoline_target is installed to skip_trampoline_code.
That means gdb configured for arm-linux target doesn't recognize some
arm specific trampolines or stubs.  Beside handling generic solib
trampoline, gdb for arm-linux target should be able to handle arm
specific trampolines.  This patch is to skip arm specific stubs, if
any, and as a fallback, skip the generic solib trampoline.

gdb:

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

	* arm-linux-tdep.c (arm_linux_skip_trampoline_code): New.
	(arm_linux_init_abi): Set skip_trampoline_code with
	gdbarch_skip_trampoline_code instead of
	find_solib_trampoline_target.
2014-06-24 09:30:34 +08:00
Yao Qi 18d18ac810 Apply stub unwinder to 'bx reg' trampoline
In target arm-none-eabi, prologue unwinder is used for trampoline
'bx reg'.  However, in target arm-linux, exidx unwinder is selected for
trampoline at first, which is not expected.  The main function and the
trampoline is,

   0x00009dfc <main+0>: push    {r4, r5, r6, r7, lr}
   ......
   0x0000ac30 <main+3636>:      ldrdeq  r3, [r1], -r8
   0x0000ac34:  bx      r2
   0x0000ac36:  bx      r4

and .ARM.exidx is:

0x9dfc <main>: @0xb404
  Compact model index: 1
  0x97      vsp = r7
  0x20      vsp = vsp + 132
  0x3f      vsp = vsp + 256
  0x80 0xf0 pop {r8, r9, r10, r11}
  0xab      pop {r4, r5, r6, r7, r14}

0xac38 <__aeabi_drsub>: 0x1 [cantunwind]

Trampolines 'bx r2' and 'bx r4' doesn't belong to main, but the exidx
for main is still selected form them because there is no end address
of each exidx entry.

Instead of teaching exidx unwinder ignore this trampoline (which looks
complicated and error prone), I decide to let stub unwinder to handle
trampoline, because stub undwinder is installed before exidx unwinder,
and this trampoline can be regarded as a stub too.

This patch is to add the code to match 'bx reg' trampoline in the
sniffer of stub unwinder.

gdb:

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

	* arm-tdep.c (arm_stub_unwind_sniffer): Return 1 if
	arm_skip_bx_reg returns	non-zero.
2014-06-24 09:30:29 +08:00
Yao Qi 80d8d3908b Skip 'bx reg' trampoline on arm-none-eabi
After this patch
<https://gcc.gnu.org/ml/gcc-patches/2005-01/msg00813.html> applied to
GCC, a new trampoline is generated but GDB doesn't recognize it.  This
patch is to teach GDB to understand this trampoline.  See details
about this trampoline and the heuristics in the comments.

gdb:

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

	* arm-tdep.c (arm_skip_bx_reg): New function.
	(arm_skip_stub): Call arm_skip_bx_reg.
2014-06-24 09:30:24 +08:00
Don Breazeal 6a18a01c33 Add myself as write-after-approval maintainer. 2014-06-23 11:27:42 -07:00
Pedro Alves 8e9db26e29 x86 Linux watchpoints: Couldn't write debug register: Invalid argument.
This patch fixes this on x86 Linux:

 (gdb) watch *buf@2
 Hardware watchpoint 8: *buf@2
 (gdb) si
 0x00000000004005a7      34        for (i = 0; i < 100000; i++); /* stepi line */
 (gdb) del
 Delete all breakpoints? (y or n) y
 (gdb) watch *(buf+1)@1
 Hardware watchpoint 9: *(buf+1)@1
 (gdb) si
 0x00000000004005a7 in main () at ../../../src/gdb/testsuite/gdb.base/watchpoint-reuse-slot.c:34
 34        for (i = 0; i < 100000; i++); /* stepi line */
 Couldn't write debug register: Invalid argument.
 (gdb)

In the example above the debug registers are being switched from this
state:

        CONTROL (DR7): 0000000000050101          STATUS (DR6): 0000000000000000
        DR0: addr=0x0000000000601040, ref.count=1  DR1: addr=0x0000000000000000, ref.count=0
        DR2: addr=0x0000000000000000, ref.count=0  DR3: addr=0x0000000000000000, ref.count=0

to this:

        CONTROL (DR7): 0000000000010101          STATUS (DR6): 0000000000000000
        DR0: addr=0x0000000000601041, ref.count=1  DR1: addr=0x0000000000000000, ref.count=0
        DR2: addr=0x0000000000000000, ref.count=0  DR3: addr=0x0000000000000000, ref.count=0

That is, before, DR7 was setup for watching a 2 byte region starting
at what's in DR0 (0x601040).

And after, DR7 is setup for watching a 1 byte region starting at
what's in DR0 (0x601041).

We always write DR0..DR3 before DR7, because if we enable a slot's
bits in DR7, you need to have already written the corresponding
DR0..DR3 registers -- the kernel rejects the DR7 write with EINVAL
otherwise.

The error shown above is the opposite scenario.  When we try to write
0x601041 to DR0, DR7's bits still indicate intent of watching a 2-byte
region.  That DR0/DR7 combination is invalid, because 0x601041 is
unaligned.  To watch two bytes, we'd have to use two slots.  So the
kernel errors out with EINVAL.

Fix this by always first clearing DR7, then writing DR0..DR3, and then
setting DR7's bits.

A little optimization -- if we're disabling the last watchpoint, then
we can clear DR7 just once.  The changes to nat/i386-dregs.c make that
easier to detect, and as bonus, they make it a little easier to make
sense of DR7 in the debug logs, as we no longer need to remember we're
seeing stale bits.

Tested on x86_64 Fedora 20, native and GDBserver.

This adds an exhaustive test that switches between many different
combinations of watchpoint types and addresses and widths.

gdb/
2014-06-23  Pedro Alves  <palves@redhat.com>

	* amd64-linux-nat.c (amd64_linux_prepare_to_resume): Clear
	DR_CONTROL before setting DR0..DR3.
	* i386-linux-nat.c (i386_linux_prepare_to_resume): Likewise.
	* nat/i386-dregs.c (i386_remove_aligned_watchpoint): Clear all
	bits of DR_CONTROL related to the debug register slot being
	disabled.  If all slots are vacant, clear local slowdown as well,
	and assert DR_CONTROL is 0.

gdb/gdbserver/
2014-06-23  Pedro Alves  <palves@redhat.com>

	* linux-x86-low.c (x86_linux_prepare_to_resume): Clear DR_CONTROL
	before setting DR0..DR3.

gdb/testsuite/
2014-06-23  Pedro Alves  <palves@redhat.com>

	* gdb.base/watchpoint-reuse-slot.c: New file.
	* gdb.base/watchpoint-reuse-slot.exp: New file.
2014-06-23 16:44:04 +01:00
Siva Chandra 70afc5b72d Align behavior of xmethod commands with that of pretty-printer commands.
Currently, the xmethod commands lookup xmethod matchers in the current
progspace even if the locus regular expression matches the progspace's
filename.  Pretty printer commands do not match the current progspace's
filename.

gdb/

	* python/lib/gdb/command/xmethods.py
	(get_method_matchers_in_loci):  Lookup xmethod matchers in the
	current progspace only if the string "progspace" matches LOCUS_RE.

gdb/testsuite

	* gdb.python/py-xmethods.exp: Use "progspace" instead of the
	progspace's filename in 'info', 'enable' and 'disable' command
	tests.
2014-06-23 04:57:51 -07:00
Jan Kratochvil b972bd9c13 testsuite: Use istarget and is_lp64_target for 3 testcases.
On x86_64 with -m32 or on i686 it will:

Running ./gdb.arch/amd64-stap-special-operands.exp ...
gdb compile failed, amd64-stap-triplet.c: Assembler messages:
amd64-stap-triplet.c:35: Error: bad register name `%rbp'
amd64-stap-triplet.c:38: Error: bad register name `%rsp'
amd64-stap-triplet.c:40: Error: bad register name `%rbp)'
amd64-stap-triplet.c:41: Error: bad register name `%rsi'
amd64-stap-triplet.c:42: Error: bad register name `%rbp)'
/tmp/ccjOdmpl.s:63: Error: bad register name `%rbp'

2014-06-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/amd64-stap-special-operands.exp: Use is_lp64_target.
	* gdb.arch/amd64-stap-optional-prefix.exp: Likewise.
	* gdb.dwarf2/dw2-error.exp: Use istarget and is_lp64_target.

Message-ID: <20140622211401.GA3716@host2.jankratochvil.net>
2014-06-23 08:24:36 +02:00
Jan Kratochvil 840ed64d1c Fix --with-system-readline with readline-6.3 patch 5
I have filed now:
	--with-system-readline uses bundled readline include files
	https://sourceware.org/bugzilla/show_bug.cgi?id=17077

To see any effect of the patch below you have to do:
	rm -rf readline
Otherwise readline include files get used the bundled ones from GDB which are
currently 6.2 while system readline may be 6.3 already.

You also have to use system readline-6.3 including its upstream patch:
	[Bug-readline] Readline-6.3 Official Patch 5
	http://lists.gnu.org/archive/html/bug-readline/2014-04/msg00018.html
	Message-ID: <140415125618.AA57598.SM@caleb.ins.cwru.edu>

In short it happens on Fedora Rawhide since:
	readline-6.3-1.fc21
	https://koji.fedoraproject.org/koji/buildinfo?buildID=538941

The error is:
	../../gdb/tui/tui-io.c:132:1: error: 'Function' is deprecated [-Werror=deprecated-declarations]
	 static Function *tui_old_rl_getc_function;
	 ^
	../../gdb/tui/tui-io.c:133:1: error: 'VFunction' is deprecated [-Werror=deprecated-declarations]
	 static VFunction *tui_old_rl_redisplay_function;
	 ^
	../../gdb/tui/tui-io.c:134:1: error: 'VFunction' is deprecated [-Werror=deprecated-declarations]
	 static VFunction *tui_old_rl_prep_terminal;
	 ^
	../../gdb/tui/tui-io.c:135:1: error: 'VFunction' is deprecated [-Werror=deprecated-declarations]
	 static VFunction *tui_old_rl_deprep_terminal;
	 ^

It is since bash change:
lib/readline/rltypedefs.h
       - remove old Function/VFunction/CPFunction/CPPFunction typedefs as
	 suggested by Tom Tromey <tromey@redhat.com>

The new typedefs used below are present in readline/rltypedefs.h since:
	git://git.savannah.gnu.org/bash.git
	commit 28ef6c316f1aff914bb95ac09787a3c83c1815fd
	Date:   Fri Apr 6 19:14:31 2001 +0000

gdb/
2014-06-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix --with-system-readline with readline-6.3 patch 5.
	* tui/tui-io.c (tui_old_rl_getc_function, tui_old_rl_redisplay_function)
	(tui_old_rl_prep_terminal, tui_old_rl_deprep_terminal): Use rl_*_t
	types.

Message-ID: <20140620105004.GA22236@host2.jankratochvil.net>
2014-06-20 17:43:56 +02:00
Tom Tromey 26f2dc3065 make obstack object allocators more type-safe
This changes OBSTACK_ZALLOC and OBSTACK_CALLOC to cast their value to
the correct type.  This is more type-safe and also is more in line
with the other object-allocation macros in libiberty.h.

Making this change revealed one trivial error in dwarf2read.c.
On the whole that seems pretty good to me.

Tested by rebuilding.

2014-06-20  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (dw2_get_real_path): Use correct type in
	OBSTACK_CALLOC.
	* gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Cast result.
2014-06-20 08:44:19 -06:00
Gary Benson 698b3e0833 Fix mingw32 build on x86-64 RHEL 6.5
This commit fixes the mingw32 build on x86-64 RHEL 6.5.

gdb/gdbserver/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* configure.ac (AC_REPLACE_FUNCS) <vasprintf, vsnprintf>: Removed.
	* configure: Regenerated.
	* config.in: Likewise.
2014-06-20 15:41:28 +01:00
Gary Benson 125f8a3dde Move shared native target specific code to gdb/nat
https://sourceware.org/gdb/wiki/Common describes the following
directory structure:

 gdb/nat/
   Native target backend files. Code that interfaces with the
   host debug API. E.g., ptrace code, Windows debug API code,
   procfs code should go here.

 gdb/target/
   Host-independent, target vector specific code (target_ops).

 gdb/common/
   All other shared code.

This commit moves all native target backend files currently in
gdb/common to gdb/nat.

gdb/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* common/gdb_thread_db.h: Moved to nat.  All includes updated.
	* common/glibc_thread_db.h: Likewise.
	* common/i386-cpuid.h: Likewise.
	* common/i386-gcc-cpuid.h: Likewise.
	* common/linux-btrace.h: Likewise.
	* common/linux-osdata.h: Likewise.
	* common/linux-procfs.h: Likewise.
	* common/linux-ptrace.h: Likewise.
	* common/mips-linux-watch.h: Likewise.
	* common/linux-btrace.c: Moved to nat.
	* common/linux-osdata.c: Likewise.
	* common/linux-procfs.c: Likewise.
	* common/linux-ptrace.c: Likewise.
	* common/mips-linux-watch.c: Likewise.
	* nat/gdb_thread_db.h: Moved from common.
	* nat/glibc_thread_db.h: Likewise.
	* nat/i386-cpuid.h: Likewise.
	* nat/i386-gcc-cpuid.h: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-btrace.h: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-osdata.h: Likewise.
	* nat/linux-procfs.c: Likewise.
	* nat/linux-procfs.h: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/linux-ptrace.h: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* nat/mips-linux-watch.h: Likewise.
	* Makefile.in (HFILES_NO_SRCDIR): Reflect new locations.
	(object file files): Reordered.
	* gdb/copyright.py (EXCLUDE_LIST): Reflect new location
	of glibc_thread_db.h.

gdb/gdbserver/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* Makefile.in (SFILES): Update locations for files moved
	from common to nat.
	(object file files): Reordered.

gdb/testsuite/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* gdb.arch/i386-avx.exp: Fix include file location.
	* gdb.arch/i386-sse.exp: Likewise.
2014-06-20 14:06:48 +01:00
Gary Benson 42995dbda6 Vectorize gdbserver x86 debug register accessors
This commit makes gdbserver access the x86 debug register accessor
functions via the same function vector as GDB proper.  This removes
a chunk of conditional code that was previously in i386-{nat,low}.h
and leaves a single macro as the only GDB/gdbserver difference in
nat/i386-dregs.c.

gdb/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* i386-nat.h (debug_hw_points): Moved to nat/i386-dregs.c.
	(i386_dr_low_type): Moved to nat/i386-dregs.h.
	(i386_dr_low): Likewise.
	(i386_dr_low_can_set_addr): Moved to nat/i386-dregs.c.
	(i386_dr_low_set_addr): Likewise.
	(i386_dr_low_get_addr): Likewise.
	(i386_dr_low_can_set_control): Likewise.
	(i386_dr_low_set_control): Likewise.
	(i386_dr_low_get_control): Likewise.
	(i386_dr_low_get_status): Likewise.
	(i386_get_debug_register_length): Likewise.
	* nat/i386-dregs.h (i386_dr_low_type): Moved from i386-nat.h.
	(i386_dr_low): Likewise.
	* nat/i386-dregs.c (i386-low.h): Remove include.
	(i386-nat.h): Likewise.
	(nat/i386-dregs.h): New include.
	(i386_dr_low_can_set_addr): Moved from i386-nat.h.
	(i386_dr_low_set_addr): Likewise.
	(i386_dr_low_get_addr): Likewise.
	(i386_dr_low_can_set_control): Likewise.
	(i386_dr_low_set_control): Likewise.
	(i386_dr_low_get_control): Likewise.
	(i386_dr_low_get_status): Likewise.
	(i386_get_debug_register_length): Likewise.
	(debug_hw_points): Likewise.

gdb/gdbserver/
2014-06-20  Gary Benson  <gbenson@redhat.com>

	* i386-low.h (i386_dr_low_can_set_addr): Removed.
	(i386_dr_low_set_addr): Likewise.
	(i386_dr_low_get_addr): Likewise.
	(i386_dr_low_can_set_control): Likewise.
	(i386_dr_low_set_control): Likewise.
	(i386_dr_low_get_control): Likewise.
	(i386_dr_low_get_status): Likewise.
	(i386_get_debug_register_length): Likewise.
	* linux-x86-low.c (i386_dr_low_set_addr):
	Changed signature.  Made static.
	(i386_dr_low_get_addr): Likewise.
	(i386_dr_low_set_control): Likewise.
	(i386_dr_low_get_control): Likewise.
	(i386_dr_low_get_status): Likewise.
	(i386_dr_low): New global variable.
	* win32-i386-low.c (i386_dr_low_set_addr):
	Changed signature.  Made static.
	(i386_dr_low_get_addr): Likewise.
	(i386_dr_low_set_control): Likewise.
	(i386_dr_low_get_control): Likewise.
	(i386_dr_low_get_status): Likewise.
	(i386_dr_low): New global variable.
2014-06-20 13:05:50 +01:00
Marcus Shawcroft e1d2394b50 Fix gdbserver cross build.
The recent libiberty patch caused issues when cross building
gdbserver.  The Makefile ends invoking the build machine's "ar"
instead of the --host version:

  ar  ./libiberty.a \
	    ./regex.o (...)

  ar: illegal option -- .
  Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...
	 ar -M [<mri-script]

The libiberty configure script does probe for and finds an appropriate
AR.  However, gdbserver's configure does not probe for AR and
overrides the AR used in the libiberty build by explicitly passing AR
to the sub-builds.

gdb/gdbserver/
2014-06-20  Marcus Shawcroft  <marcus.shawcroft@arm.com>

	* configure.ac: Invoke. AC_CHECK_TOOL(AR, ar).
	* Makefile.in (AR, AR_FLAGS): Define.
	* configure: Regenerate.
2014-06-20 11:48:15 +01:00
Iain Buclaw 3ed9baed43 Initial pass at D language expression parser support.
gdb/
2014-06-05  Iain Buclaw  <ibuclaw@gdcproject.org>

	* Makefile.in (SFILES): Add d-exp.y.
	(YYFILES): Add d-exp.c.
	(YYOBJ): Add d-exp.o.
	(local-maintainer-clean): Delete d-exp.c.
	* d-exp.y: New file.
	* d-lang.h (d_parse): New declaration.
	(d_error): New declaration.
	* d-lang.c (d_op_print_tab): Add entry for BINOP_CONCAT and BINOP_EXP.
	Set BINOP_EQUAL and BINOP_NOTEQUAL to same precedence as other
	PREC_ORDER operators.
	(d_language_defn): Use d_parse, d_error instead of c_parse, c_error.

gdb/testsuite/
2014-06-05  Iain Buclaw  <ibuclaw@gdcproject.org>

	* gdb.dlang/expression.exp: New file.
2014-06-19 19:30:20 +01:00
Yao Qi 78c164b006 Remove any_running
Function any_running isn't used.  This patch is to remove it.
Rebuild GDB for linux and mingw.

gdb:

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

	* gdbthread.h (any_running): Remove the declaration.
	* thread.c (any_running): Remove.
2014-06-19 20:15:06 +08:00
Yao Qi f6e29b6ec0 Use enum thread_state
This patch is to change field state's type to 'enum thread_state', and
replace RUNNING with THREAD_RUNNING and STOPPED with THREAD_STOPPED
respectively in comments.

gdb:

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

	* gdbthread.h (struct thread_info) <state>: Change its type to
	'enum thread_state'.  Update comments.
2014-06-19 20:14:43 +08:00
Pedro Alves 034f788c5e Fix next over threaded execl with "set scheduler-locking step".
Running gdb.threads/thread-execl.exp with scheduler-locking set to
"step" reveals a problem:

 (gdb) next^M
 [Thread 0x7ffff7fda700 (LWP 27168) exited]^M
 [New LWP 27168]^M
 [Thread 0x7ffff74ee700 (LWP 27174) exited]^M
 process 27168 is executing new program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.threads/thread-execl^M
 [Thread debugging using libthread_db enabled]^M
 Using host libthread_db library "/lib64/libthread_db.so.1".^M
 infrun.c:5225: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)' failed.^M
 A problem internal to GDB has been detected,^M
 further debugging may prove unreliable.^M
 Quit this debugging session? (y or n) FAIL: gdb.threads/thread-execl.exp: schedlock step: get to main in new image (GDB internal error)

The assertion is correct.  The issue is that GDB is mistakenly trying
to switch back to an exited thread, that was previously stepping when
it exited.  This is exactly the sort of thing the test wants to make
sure doesn't happen:

	# Now set a breakpoint at `main', and step over the execl call.  The
	# breakpoint at main should be reached.  GDB should not try to revert
	# back to the old thread from the old image and resume stepping it

We don't see this bug with schedlock off only because a different
sequence of events makes GDB manage to delete the thread instead of
marking it exited.

This particular internal error can be fixed by making the loop over
all threads in switch_back_to_stepped_thread skip exited threads.
But, looking over other ALL_THREADS users, all either can or should be
skipping exited threads too.  So for simplicity, this patch replaces
ALL_THREADS with a new macro that skips exited threads itself, and
updates everything to use it.

Tested on x86_64 Fedora 20.

gdb/
2014-06-19  Pedro Alves  <palves@redhat.com>

	* gdbthread.h (ALL_THREADS): Delete.
	(ALL_NON_EXITED_THREADS): New macro.
	* btrace.c (btrace_free_objfile): Use ALL_NON_EXITED_THREADS
	instead of ALL_THREADS.
	* infrun.c (find_thread_needs_step_over)
	(switch_back_to_stepped_thread): Use ALL_NON_EXITED_THREADS
	instead of ALL_THREADS.
	* record-btrace.c (record_btrace_open)
	(record_btrace_stop_recording, record_btrace_close)
	(record_btrace_is_replaying, record_btrace_resume)
	(record_btrace_find_thread_to_move, record_btrace_wait): Likewise.
	* remote.c (append_pending_thread_resumptions): Likewise.
	* thread.c (thread_apply_all_command): Likewise.

gdb/testsuite/
2014-06-19  Pedro Alves  <palves@redhat.com>

	* gdb.threads/thread-execl.exp (do_test): New procedure, factored
	out from ...
	(top level): ... here.  Iterate running tests under different
	scheduler-locking settings.
2014-06-19 11:59:03 +01:00
Gary Benson 46e3325277 Directly call i386-dregs functions
Three target_ops functions in i386-nat.c call other local target_ops
functions.  This commit changes those functions to call the functions
in i386-dregs.c directly.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_stopped_by_watchpoint):
	Use i386_dr_stopped_by_watchpoint.
	(i386_insert_hw_breakpoint): Use i386_dr_insert_watchpoint.
	(i386_remove_hw_breakpoint): Use i386_dr_remove_watchpoint.
2014-06-19 10:56:16 +01:00
Gary Benson 3a8ee006fb Create nat/i386-dregs.c
This commit moves code to be shared from i386-{nat,low}.[ch]
into a new file, nat/i386-dregs.c.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* nat/i386-dregs.c: New file.
	* Makefile.in (i386-dregs.o): New rule.
	* config/i386/cygwin.mh (NATDEPFILES): Add i386-dregs.o.
	* config/i386/cygwin64.mh (NATDEPFILES): Likewise.
	* config/i386/darwin.mh (NATDEPFILES): Likewise.
	* config/i386/fbsd.mh (NATDEPFILES): Likewise.
	* config/i386/fbsd64.mh (NATDEPFILES): Likewise.
	* config/i386/go32.mh (NATDEPFILES): Likewise.
	* config/i386/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux64.mh (NATDEPFILES): Likewise.
	* config/i386/mingw.mh (NATDEPFILES): Likewise.
	* config/i386/mingw64.mh (NATDEPFILES): Likewise.
	* i386-nat.h (debug_hw_points): New declaration.
	* i386-nat.c (breakpoint.h): Remove include.
	(command.h): Likewise.
	(target.h): Likewise.
	(gdb_assert.h): Likewise.
	(debug_hw_points): Made nonstatic.
	(debug_printf): Now in i386-dregs.c.
	(TARGET_HAS_DR_LEN_8): Likewise.
	(DR_CONTROL_SHIFT): Likewise.
	(DR_CONTROL_SIZE): Likewise.
	(DR_RW_EXECUTE): Likewise.
	(DR_RW_WRITE): Likewise.
	(DR_RW_READ): Likewise.
	(DR_RW_IORW): Likewise.
	(DR_LEN_1): Likewise.
	(DR_LEN_2): Likewise.
	(DR_LEN_4): Likewise.
	(DR_LEN_8): Likewise.
	(DR_LOCAL_ENABLE_SHIFT): Likewise.
	(DR_GLOBAL_ENABLE_SHIFT): Likewise.
	(DR_ENABLE_SIZE): Likewise.
	(DR_LOCAL_SLOWDOWN): Likewise.
	(DR_GLOBAL_SLOWDOWN): Likewise.
	(DR_CONTROL_RESERVED): Likewise.
	(I386_DR_CONTROL_MASK): Likewise.
	(I386_DR_VACANT): Likewise.
	(I386_DR_LOCAL_ENABLE): Likewise.
	(I386_DR_GLOBAL_ENABLE): Likewise.
	(I386_DR_DISABLE): Likewise.
	(I386_DR_SET_RW_LEN): Likewise.
	(I386_DR_GET_RW_LEN): Likewise.
	(I386_DR_WATCH_HIT): Likewise.
	(i386_wp_op_t): Likewise.
	(i386_show_dr): Likewise.
	(i386_length_and_rw_bits): Likewise.
	(i386_insert_aligned_watchpoint): Likewise.
	(i386_remove_aligned_watchpoint): Likewise.
	(i386_handle_nonaligned_watchpoint): Likewise.
	(i386_update_inferior_debug_regs): Likewise.
	(i386_insert_watchpoint): Use i386_dr_insert_watchpoint.
	(i386_remove_watchpoint): Use i386_dr_remove_watchpoint.
	(i386_region_ok_for_watchpoint):
	Use i386_dr_region_ok_for_watchpoint.
	(i386_stopped_data_address): Use i386_dr_stopped_data_address.

gdb/gdbserver/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* Makefile.in (i386-dregs.o): New rule.
	* configure.srv: Add i386-dregs.o to all targets using i386-low.o.
	* i386-low.c (target.h): Remove include.
	(TARGET_HAS_DR_LEN_8): Now in i386-dregs.c.
	(DR_CONTROL_SHIFT): Likewise.
	(DR_CONTROL_SIZE): Likewise.
	(DR_RW_EXECUTE): Likewise.
	(DR_RW_WRITE): Likewise.
	(DR_RW_READ): Likewise.
	(DR_RW_IORW): Likewise.
	(DR_LEN_1): Likewise.
	(DR_LEN_2): Likewise.
	(DR_LEN_4): Likewise.
	(DR_LEN_8): Likewise.
	(DR_LOCAL_ENABLE_SHIFT): Likewise.
	(DR_GLOBAL_ENABLE_SHIFT): Likewise.
	(DR_ENABLE_SIZE): Likewise.
	(DR_LOCAL_SLOWDOWN): Likewise.
	(DR_GLOBAL_SLOWDOWN): Likewise.
	(DR_CONTROL_RESERVED): Likewise.
	(I386_DR_CONTROL_MASK): Likewise.
	(I386_DR_VACANT): Likewise.
	(I386_DR_LOCAL_ENABLE): Likewise.
	(I386_DR_GLOBAL_ENABLE): Likewise.
	(I386_DR_DISABLE): Likewise.
	(I386_DR_SET_RW_LEN): Likewise.
	(I386_DR_GET_RW_LEN): Likewise.
	(I386_DR_WATCH_HIT): Likewise.
	(i386_wp_op_t): Likewise.
	(i386_show_dr): Likewise.
	(i386_length_and_rw_bits): Likewise.
	(i386_insert_aligned_watchpoint): Likewise.
	(i386_remove_aligned_watchpoint): Likewise.
	(i386_handle_nonaligned_watchpoint): Likewise.
	i386_update_inferior_debug_regs(): Likewise.
	(i386_dr_insert_watchpoint): Likewise.
	(i386_dr_remove_watchpoint): Likewise.
	(i386_dr_region_ok_for_watchpoint): Likewise.
	(i386_dr_stopped_data_address): Likewise.
	(i386_dr_stopped_by_watchpoint): Likewise.
2014-06-19 10:56:00 +01:00
Gary Benson 322a8e06b9 Refactor i386_{insert,remove}_hw_breakpoint
This commit refactors i386_{insert,remove}_hw_breakpoint
to call i386_{insert,remove}_watchpoint rather than
duplicating functionality.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_insert_hw_breakpoint): Use
	i386_insert_watchpoint.
	(i386_remove_hw_breakpoint): Use i386_remove_watchpoint.
2014-06-19 10:55:12 +01:00
Gary Benson 8f26655c9e Partially revert 4be83cc2b2
The above commit did two things:

 1) A number of functions were renamed and made nonstatic.
 2) A number of other functions were renamed only.

This commit reverts #1 but not #2.  In addition, prototypes for
functions now remade static have been removed from i386-dregs.h.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_dr_show): Renamed to
	i386_show_dr and made static.  All uses updated.
	(i386_dr_length_and_rw_bits): Renamed to
	i386_length_and_rw_bits and made static.
	All uses updated.
	(i386_dr_insert_aligned_watchpoint): Renamed to
	i386_insert_aligned_watchpoint and made static.
	All uses updated.
	(i386_dr_remove_aligned_watchpoint): Renamed to
	i386_remove_aligned_watchpoint and made static.
	All uses updated.
	(i386_dr_update_inferior_debug_regs): Renamed to
	i386_update_inferior_debug_regs and made static.
	All uses updated.
	* nat/i386-dregs.h (i386_dr_show): Removed.
	(i386_dr_length_and_rw_bits): Likewise.
	(i386_dr_insert_aligned_watchpoint): Likewise.
	(i386_dr_remove_aligned_watchpoint): Likewise.
	(i386_dr_update_inferior_debug_regs): Likewise.

gdb/gdbserver/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* i386-low.c (i386_dr_show): Renamed to
	i386_show_dr and made static.  All uses updated.
	(i386_dr_length_and_rw_bits): Renamed to
	i386_length_and_rw_bits and made static.
	All uses updated.
	(i386_dr_insert_aligned_watchpoint): Renamed to
	i386_insert_aligned_watchpoint and made static.
	All uses updated.
	(i386_dr_remove_aligned_watchpoint): Renamed to
	i386_remove_aligned_watchpoint and made static.
	All uses updated.
	(i386_dr_update_inferior_debug_regs): Renamed to
	i386_update_inferior_debug_regs and made static.
	All uses updated.
2014-06-19 10:54:50 +01:00
Gary Benson 992c7d700f Demangler crash handler
This commit wraps calls to the demangler with a segmentation fault
handler.  The first time a segmentation fault is caught a core file
is generated and the user is prompted to file a bug and offered the
choice to exit or to continue their GDB session.  A maintainence
option is provided to allow the user to disable the crash handler
if required.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* configure.ac [AC_CHECK_FUNCS] <sigaltstack>: New check.
	* configure: Regenerate.
	* config.in: Likewise.
	* main.c (signal.h): New include.
	(setup_alternate_signal_stack): New function.
	(captured_main): Call the above.
	* cp-support.c (signal.h): New include.
	(catch_demangler_crashes): New flag.
	(SIGJMP_BUF): New define.
	(SIGSETJMP): Likewise.
	(SIGLONGJMP): Likewise.
	(gdb_demangle_jmp_buf): New static global.
	(gdb_demangle_attempt_core_dump): Likewise.
	(gdb_demangle_signal_handler): New function.
	(gdb_demangle): If catch_demangler_crashes is set, install the
	above signal handler before calling bfd_demangle, and restore
	the original signal handler afterwards.  Display the offending
	symbol and call demangler_warning the first time a segmentation
	fault is caught.
	(_initialize_cp_support): New maint set/show command.

gdb/doc/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document new
	"maint set/show catch-demangler-crashes" option.
2014-06-19 09:13:57 +01:00
Gary Benson eae7090bea Refactor and expose core-dumping functionality
This commit exposes the functions that dump core outside utils.c.
can_dump_core gains a new parameter, "limit_kind", to allow either
the soft or hard limit to be checked, and its printing has separated
into the new function warn_cant_dump_core.  The new function
can_dump_core_warn does what can_dump_core previously did (print and
warn).

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* utils.h (resource_limit_kind): New enum.
	(can_dump_core): New declaration.
	(warn_cant_dump_core): Likewise.
	(dump_core): Likewise.
	* utils.c (dump_core): Made nonstatic.  Added new
	parameter "limit_kind".
	(can_dump_core): Made nonstatic. Moved printing code to...
	(warn_cant_dump_core): New function.
	(can_dump_core_warn): Likewise.
	(internal_vproblem): Replace calls to can_dump_core with
	calls to can_dump_core_warn.  Supply new argument to each.
2014-06-19 09:12:26 +01:00
Gary Benson 57fcfb1b20 Add new internal problem for demangler warnings
This commit adds a new category of internal problem for demangler
warnings.  Demangler warnings behave in much the same way as internal
warnings except that they do not create core files and no option to
change this is presented to the user.

gdb/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* utils.h (demangler_vwarning): New declaration.
	(demangler_warning): Likewise.
	* utils.c (struct internal_problem)
	<user_settable_should_quit>: New field.
	<user_settable_should_dump_core>: Likewise
	(internal_error_problem): Add values for above new fields.
	(internal_warning_problem): Likewise.
	(demangler_warning_problem): New static global.
	(demangler_vwarning): New function.
	(demangler_warning): Likewise.
	(add_internal_problem_command): Selectively add commands.
	(_initialize_utils): New internal problem command.
	* maint.c (maintenance_demangler_warning): New function.
	(_initialize_maint_cmds): New command.

gdb/doc/
2014-06-19  Gary Benson  <gbenson@redhat.com>

	* gdb.texinfo (Maintenance Commands): Document new
	"maint demangler-warning" command and new
	"maint set/show demangler-warning" option.
2014-06-19 09:10:44 +01:00
Luis Machado 45371d0cee The testcase was generating DW_AT_high_pc and DW_AT_low_pc entries
with type DW_FORM_string, which is wrong.

GDB was using that information to load data as strings, and then
proceeded to use the string pointers as addresses.

Even then, the test was passing just fine, because we were lucky
enough to have the low_pc string pointer smaller than the high_pc
string pointer.

Two issues are fixed.  The first one is the DW_FORM_string type. The
second one is adjusting the addresses so that they are non-zero,
since GDB doesn't like seeing 0 in these fields due to a check
contained in dwarf2_get_pc_bounds:

  if (low == 0 && !dwarf2_per_objfile->has_section_at_zero)
    return 0;

With both fixes, the testcase passes deterministically.

2014-06-19  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.cp/nsalias.exp: Set type of low_pc and high_pc entries
	to DW_FORM_addr and use non-zero addresses.
2014-06-19 07:07:48 +01:00
Tom Tromey 17a40b44e2 make common_block const
This changes general_symbol_info to make "common_block" const.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* f-valprint.c (info_common_command_for_block): Update.
	* symtab.h (struct general_symbol_info) <common_block>: Now
	const.
2014-06-18 08:17:00 -06:00
Tom Tromey 346d1dfebd constify some blockvector APIs
Generally, the blockvector ought to be readonly.  So, this patch makes
the blockvector const in the symtab, and also changes various
blockvector APIs to be const.

This patch has a couple of spots that cast away const.  I consider
these to be ok because they occur in mdebugread and are used while
constructing the blockvector.  I have added comments at these spots.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* symtab.h (struct symtab) <blockvector>: Now const.
	* ada-lang.c (ada_add_global_exceptions): Update.
	* buildsym.c (augment_type_symtab): Update.
	* dwarf2read.c (dw2_lookup_symbol): Update.
	* jit.c (finalize_symtab): Update.
	* jv-lang.c (add_class_symtab_symbol): Update.
	* mdebugread.c (parse_symbol, add_block, sort_blocks, new_symtab):
	Update.
	* objfiles.c (objfile_relocate1): Update.
	* psymtab.c (lookup_symbol_aux_psymtabs)
	(maintenance_check_psymtabs): Update.
	* python/py-symtab.c (stpy_global_block, stpy_static_block):
	Update.
	* spu-tdep.c (spu_catch_start): Update.
	* symmisc.c (dump_symtab_1): Update.
	* symtab.c (lookup_global_symbol_from_objfile)
	(lookup_symbol_aux_objfile, lookup_symbol_aux_quick)
	(basic_lookup_transparent_type_quick)
	(basic_lookup_transparent_type, find_pc_sect_symtab)
	(find_pc_sect_line, search_symbols): Update.
	* block.c (find_block_in_blockvector): Make "bl" const.
	(blockvector_for_pc_sect, blockvector_for_pc): Make return type
	const.
	(blockvector_contains_pc): Make "bv" const.
	(block_for_pc_sect): Update.
	* block.h (blockvector_for_pc, blockvector_for_pc_sect)
	(blockvector_contains_pc): Update.
	* breakpoint.c (resolve_sal_pc): Update.
	* inline-frame.c (block_starting_point_at): Update.
2014-06-18 08:16:59 -06:00
Tom Tromey 1834676b5f constify complete_line
This changes complete_line to take a const parameter.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* completer.c (complete_line): Make "line_buffer" const.
	* completer.h (complete_line): Update.
2014-06-18 08:16:58 -06:00
Tom Tromey ac1a991b1c remove unneeded cast in symtab.c
This removes an unneeded const cast from symtab.c:add_macro_name.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* symtab.c (add_macro_name): Remove unneeded cast.
2014-06-18 08:16:57 -06:00
Tom Tromey 5bc98e5269 constify parse_cli_boolean_value
This changes a parameter of parse_cli_boolean_value to be const.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* cli/cli-setshow.h (parse_cli_boolean_value): Update.
	* cli/cli-setshow.c (parse_cli_boolean_value): Make "arg" const.
2014-06-18 08:16:56 -06:00
Tom Tromey 8236def8eb constify probe.c function
This constifies an argument to info_probes_for_ops.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* probe.c (info_probes_for_ops): Make "arg" const.
	* probe.h (info_probes_for_ops): Update.
2014-06-18 08:16:54 -06:00
Tom Tromey 3977b71f1d constify struct block in some places
This makes some spots in gdb, particularly general_symbol_info, use a
"const struct block", then fixes the fallout.

The justification is that, ordinarily, blocks ought to be readonly.
Note though that we can't add "const" in the blockvector due to block
relocation.  This can be done once blocks are made independent of the
program space.

2014-06-18  Tom Tromey  <tromey@redhat.com>

	* varobj.c (varobj_create): Update.
	* valops.c (value_of_this): Update.
	* tracepoint.c (add_local_symbols, scope_info): Update.
	* symtab.h (struct general_symbol_info) <block>: Now const.
	* symtab.c (skip_prologue_sal)
	(default_make_symbol_completion_list_break_on)
	(skip_prologue_using_sal): Update.
	* stack.h (iterate_over_block_locals)
	(iterate_over_block_local_vars): Update.
	* stack.c (print_frame_args): Update.
	(iterate_over_block_locals, iterate_over_block_local_vars): Make
	parameter const.
	(get_selected_block): Make return type const.
	* python/py-frame.c (frapy_block): Update.
	* python/py-block.c (gdbpy_block_for_pc): Update.
	* p-exp.y (%union) <bval>: Now const.
	* mi/mi-cmd-stack.c (list_args_or_locals): Update.
	* mdebugread.c (mylookup_symbol, parse_procedure): Update.
	* m2-exp.y (%union) <bval>: Now const.
	* linespec.c (get_current_search_block): Make return type const.
	(create_sals_line_offset, find_label_symbols): Update.
	* inline-frame.c (inline_frame_sniffer, skip_inline_frames):
	Update.
	(block_starting_point_at): Make "block" const.
	* infrun.c (insert_exception_resume_breakpoint): Make "b" const.
	(check_exception_resume): Update.
	* guile/scm-frame.c (gdbscm_frame_block): Update.
	* guile/scm-block.c (gdbscm_lookup_block): Update.
	* frame.h (get_frame_block): Update.
	(get_selected_block): Make return type const.
	* frame.c (frame_id_inner): Update.
	* f-valprint.c (info_common_command_for_block)
	(info_common_command): Update.
	* dwarf2loc.c (dwarf2_find_location_expression)
	(dwarf_expr_frame_base, dwarf2_compile_expr_to_ax)
	(locexpr_describe_location_piece): Update.
	* c-exp.y (%union) <bval>: Now const.
	* breakpoint.c (resolve_sal_pc): Update.
	* blockframe.c (get_frame_block):Make return type const.
	(get_pc_function_start, get_frame_function, find_pc_sect_function)
	(block_innermost_frame): Update.
	* block.h (blockvector_for_pc, blockvector_for_pc_sect)
	(block_for_pc, block_for_pc_sect): Update.
	* block.c (blockvector_for_pc_sect, blockvector_for_pc): Make
	'pblock' const.
	(block_for_pc_sect, block_for_pc): Make return type const.
	* ax-gdb.c (gen_expr): Update.
	* alpha-mdebug-tdep.c (find_proc_desc): Update.
	* ada-lang.c (ada_read_renaming_var_value): Make 'block' const.
	(ada_make_symbol_completion_list, ada_add_exceptions_from_frame)
	(ada_read_var_value): Update.
	* ada-exp.y (struct name_info) <block>: Now const.
	(%union): Likewise.
	(block_lookup): Constify.
2014-06-18 08:16:52 -06:00
Siva Chandra 5d376983ca Make xmethods tests not to depend on inferior IO.
gdb/testsuite/

	PR gdb/17017
	* gdb.python/py-xmethods.cc: Add global function call counters and
	increment them in their respective functions.  Remove "cout"
	statements.
	* gdb.python/py-xmethods.exp: Make tests check the global function
	call counters instead of depending on inferior IO.
2014-06-18 04:31:47 -07:00
Gary Benson 5171def394 Move macros from i386-{nat,low}.c to i386-{nat,low}.h
This commit moves macros required by the soon-to-be-created
nat/i386-dregs.c into i386-{nat,low}.h.
2014-06-18 11:46:51 +01:00
Gary Benson b922889128 Create nat/i386-dregs.h
This commit moves code to be shared from i386-{nat,low}.[ch]
into a new file, nat/i386-dregs.h.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* nat/i386-dregs.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add the above.
	* i386-nat.h (i386-dregs.h): New include.
	(DR_FIRSTADDR): Now in i386-dregs.h.
	(DR_LASTADDR): Likewise.
	(DR_NADDR): Likewise.
	(DR_STATUS): Likewise.
	(DR_CONTROL): Likewise.
	(i386_debug_reg_state): Likewise.
	* i386-nat.c (ALL_DEBUG_REGISTERS): Likewise.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.h (i386-dregs.h): New include.
	(DR_FIRSTADDR): Now in i386-dregs.h.
	(DR_LASTADDR): Likewise.
	(DR_NADDR): Likewise.
	(DR_STATUS): Likewise.
	(DR_CONTROL): Likewise.
	(i386_debug_reg_state): Likewise.
	(i386_dr_insert_watchpoint): Likewise.
	(i386_dr_remove_watchpoint): Likewise.
	(i386_dr_region_ok_for_watchpoint): Likewise.
	(i386_dr_stopped_data_address): Likewise.
	(i386_dr_stopped_by_watchpoint): Likewise.
	* i386-low.c (ALL_DEBUG_REGISTERS): Likewise.
2014-06-18 11:46:35 +01:00
Luis Machado a1aa2221cb Symptom:
Using the test program gdb.base/foll-fork.c, with follow-fork-mode set to
"child" and detach-on-fork set to "off", stepping or running past the fork
call results in the child process running to completion, when it should
just finish the single step.  In addition, the breakpoint is not removed
from the parent process, so if it is resumed it receives a SIGTRAP.

Cause:

No matter what the setting for detach-on-fork, when stepping past a fork,
the single-step breakpoint (step_resume_breakpoint) is not handled
correctly in the parent.  The SR breakpoint is cloned for the child
process, but before the clone is associated with the child it is treated as
a duplicate of the original, associated wth the parent.  This results in
the insertion state of the original SR breakpoint and the clone being
"swapped" by breakpoint.c:update_global_location_list, so that the clone is
marked as inserted.

In the case where the parent is not detached, the two breakpoints remain in
that state.  The breakpoint is never inserted in the child, because
although the cloned SR breakpoint is associated with the child, it is
marked as inserted.  When the child is resumed, it runs to completion.  The
breakpoint is never removed from the parent, so that if it is resumed after
the child exits, it gets a SIGTRAP.

Here is the sequence of events:

1) handle_inferior_event: FORK event is recognized.

2) handle_inferior_event: detach_breakpoints removes all breakpoints
from the child.

3) follow_fork: the parent SR breakpoint is cloned.  Part of this procedure
is to call update_global_location_list, which swaps the insertion state of
the original and cloned SR breakpoints as part of ensuring that duplicate
breakpoints are only inserted once.  At this point the original SR
breakpoint is not marked as inserted, and the clone is.  The breakpoint is
actually inserted in the parent but not the child.

4) follow_fork: the original breakpoint is deleted by calling
delete_step_resume_breakpoint.  Since the original is not marked as
inserted, the actual breakpoint remains in the parent process.
update_global_location_list is called again as part of the deletion.  The
clone is still associated with the parent, but since it is marked as
enabled and inserted, the breakpoint is left in the parent.

5) follow_fork: if detach-on-fork is 'on', the actual breakpoint will be
removed from the parent in target_detach, based on the cloned breakpoint
still associated with the parent.  Then the clone is no longer marked as
inserted.  In follow_inferior_reset_breakpoints the clone is associated
with the child, and can be inserted.

If detach-on-fork is 'off', the actual breakpoint in the parent is never
removed (although the breakpoint had been deleted from the list).  Since
the clone continues to be marked 'inserted', the SR breakpoint is never
inserted in the child.

Fix:

Set the cloned breakpoint as disabled from the moment it is created.  This
is done by modifying clone_momentary_breakpoint to take an additional
argument, LOC_ENABLED, which is used as the value of the
bp_location->enabled member.  The clone must be disabled at that point
because clone_momentary_breakpoint calls update_global_location_list, which
will swap treat the clone as a duplicate of the original breakpoint if it
is enabled.

All the calls to clone_momentary_breakpoint had to be modified to pass '1'
or '0'.  I looked at implementing an enum for the enabled member, but
concluded that readability would suffer because there are so many places it
is used as a boolean, e.g. "if (bl->enabled)".

In follow_inferior_reset_breakpoints the clone is set to enabled once it
has been associated with the child process.  With this, the bp_location
'inserted' member is maintained correctly throughout the follow-fork
procedure and the behavior is as expected.

The same treatment is given to the exception_resume_breakpoint when
following a fork.

Testing:

Ran 'make check' on Linux x64.

Along with the fix above, the coverage of the follow-fork test
gdb.base/foll-fork.exp was expanded to:

1) cover all the combinations of values for
   follow-fork-mode and detach-on-fork

2) make sure that both user breakpoints and
   single-step breakpoints are propagated
   correctly to the child

3) check that the inferior list has the
   expected contents after following the fork.

4) check that unfollowed, undetached inferiors
   can be resumed.

gdb/

2014-06-18  Don Breazeal  <donb@codesourcery.com>

	* breakpoint.c (set_longjmp_breakpoint): Call
	momentary_breakpoint_from_master with additional argument.
	(set_longjmp_breakpoint_for_call_dummy): Call
	momentary_breakpoint_from_master with additional argument.
	(set_std_terminate_breakpoint): Call
	momentary_breakpoint_from_master with additional argument.
	(momentary_breakpoint_from_master): Add argument to function
	definition and use it to initialize structure member flag.
	(clone_momentary_breakpoint): Call
	momentary_breakpoint_from_master with additional argument.
	* infrun.c (follow_inferior_reset_breakpoints): Clear structure
	member flags set in momentary_breakpoint_from_master.

gdb/testsuite/

2014-06-18  Don Breazeal  <donb@codesourcery.com>

	* gdb.base/foll-fork.exp (default_fork_parent_follow):
	Deleted procedure.
	(explicit_fork_parent_follow): Deleted procedure.
	(explicit_fork_child_follow): Deleted procedure.
	(test_follow_fork): New procedure.
	(do_fork_tests): Replace calls to deleted procedures with
	calls to test_follow_fork and reset GDB for subsequent
	procedure calls.
2014-06-18 10:25:47 +01:00
Gary Benson 4be83cc2b2 Rename functions and make nonstatic as necessary
This commit renames the functions that are to be shared.
Functions to be shared that were static are made nonstatic.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_show_dr): Renamed to
	i386_dr_show and made nonstatic.  All uses updated.
	(i386_length_and_rw_bits): Renamed to
	i386_dr_length_and_rw_bits and made nonstatic.
	All uses updated.
	(i386_insert_aligned_watchpoint): Renamed to
	i386_dr_insert_aligned_watchpoint and made nonstatic.
	All uses updated.
	(i386_remove_aligned_watchpoint): Renamed to
	i386_dr_remove_aligned_watchpoint and made nonstatic.
	All uses updated.
	(i386_update_inferior_debug_regs): Renamed to
	i386_dr_update_inferior_debug_regs and made nonstatic.
	All uses updated.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.h (i386_low_insert_watchpoint): Renamed to
	i386_dr_insert_watchpoint.
	(i386_low_remove_watchpoint): Renamed to
	i386_dr_remove_watchpoint.
	(i386_low_region_ok_for_watchpoint): Renamed to
	i386_dr_region_ok_for_watchpoint.
	(i386_low_stopped_data_address): Renamed to
	i386_dr_stopped_data_address.
	(i386_low_stopped_by_watchpoint): Renamed to
	i386_dr_stopped_by_watchpoint.
	* i386-low.c (i386_show_dr): Renamed to
	i386_dr_show and made nonstatic.  All uses updated.
	(i386_length_and_rw_bits): Renamed to
	i386_dr_length_and_rw_bits and made nonstatic.
	All uses updated.
	(i386_insert_aligned_watchpoint): Renamed to
	i386_dr_insert_aligned_watchpoint and made nonstatic.
	All uses updated.
	(i386_remove_aligned_watchpoint): Renamed to
	i386_dr_remove_aligned_watchpoint and made nonstatic.
	All uses updated.
	(i386_update_inferior_debug_regs): Renamed to
	i386_dr_update_inferior_debug_regs and made nonstatic.
	All uses updated.
	(i386_low_insert_watchpoint): Renamed to
	i386_dr_insert_watchpoint.  All uses updated.
	(i386_low_remove_watchpoint): Renamed to
	i386_dr_remove_watchpoint.  All uses updated.
	(i386_low_region_ok_for_watchpoint): Renamed to
	i386_dr_region_ok_for_watchpoint.  All uses updated.
	(i386_low_stopped_data_address): Renamed to
	i386_dr_stopped_data_address.  All uses updated.
	(i386_low_stopped_by_watchpoint): Renamed to
	i386_dr_stopped_by_watchpoint.  All uses updated.
2014-06-18 10:15:27 +01:00
Gary Benson 131aa0d4fe Abstract i386_dr_low access
This commit adds macros to abstract access to the i386_dr_low
function vector used by i386-nat.c.  The macros are named so
as to match the names of the functions that do the same work
in gdbserver.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_dr_low_can_set_addr): New macro.
	(i386_dr_low_can_set_control): Likewise.
	(i386_dr_low_set_addr): Likewise.
	(i386_dr_low_set_control): Likewise.
	(i386_dr_low_get_addr): Likewise.
	(i386_dr_low_get_status): Likewise.
	(i386_dr_low_get_control): Likewise.
	(i386_insert_aligned_watchpoint): Use new macros.
	(i386_update_inferior_debug_regs): Likewise.
	(i386_stopped_data_address): Likewise.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.c (i386_dr_low_can_set_addr): New macro.
	(i386_dr_low_can_set_control): Likewise.
	(i386_insert_aligned_watchpoint): New check.
2014-06-18 10:15:25 +01:00
Gary Benson d9305f7fef Merge i386_update_inferior_debug_regs
This commit synchronizes the i386_update_inferior_debug_regs functions
in i386-nat.c and i386-low.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_update_inferior_debug_regs) <state>:
	New parameter.  All uses updated.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.c (i386_update_inferior_debug_regs) <inf_state>:
	Renamed to state.
2014-06-18 10:15:23 +01:00
Gary Benson ea008da432 Rename maint_show_dr to debug_hw_points
This commit renames maint_show_dr to debug_hw_points in i386-nat.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (maint_show_dr): Renamed to debug_hw_points.
	All uses updated.
2014-06-18 10:15:21 +01:00
Gary Benson e927c9fccb Merge error handling
This commit makes all error handling in i386-low.c use internal_error
rather than fatal and error.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.c (i386_length_and_rw_bits): Use internal_error
	instead of fatal and error.
	(i386_handle_nonaligned_watchpoint): Likewise.
2014-06-18 10:15:19 +01:00
Gary Benson 1b6d4134c7 Merge printing code
This commit synchronizes the debug printing code in i386-nat.c and
i386-low.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (debug_printf): New macro.
	(i386_get_debug_register_length): Likewise.
	(TARGET_HAS_DR_LEN_8): Use above macro.
	(i386_show_dr): Use debug_printf instead of puts_unfiltered
	and printf_unfiltered.  Use phex to format values.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.c (i386_get_debug_register_length): New macro.
	(TARGET_HAS_DR_LEN_8): Remove conditional.  Use above macro.
	(i386_show_dr): Use debug_printf instead of fprintf.  Use
	phex to format values.
2014-06-18 10:15:17 +01:00
Gary Benson 9b4550ef5e Add a const
This commit adds a const that was in i386-low.c but not in i386-nat.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_handle_nonaligned_watchpoint) <size_try_array>:
	Make const.
2014-06-18 10:15:15 +01:00
Gary Benson 6e62758f02 Comment changes
This commit fixes various comment differences between
i386-nat.[ch] and i386-low.[ch].

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c: Comment changes.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.h: Comment changes.
	* i386-low.c: Likewise.
2014-06-18 10:15:08 +01:00
Gary Benson 51c79e94b2 Remove unused macro
This commit removes an unused macro from i386-nat.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (I386_DR_WATCH_MASK): Remove macro.
2014-06-18 10:15:05 +01:00
Gary Benson 3e11889a6e Remove unnecessary prototypes
This commit removes four unnecessary prototypes from i386-nat.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c (i386_length_and_rw_bits): Remove prototype.
	(i386_insert_aligned_watchpoint): Likewise.
	(i386_remove_aligned_watchpoint): Likewise.
	(i386_handle_nonaligned_watchpoint): Likewise.
2014-06-18 10:14:59 +01:00
Gary Benson fc6e2f03be Whitespace changes
This commit fixes various whitespace differences between i386-nat.c
and i386-low.c.

gdb/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-nat.c: Whitespace changes.

gdb/gdbserver/
2014-06-18  Gary Benson  <gbenson@redhat.com>

	* i386-low.c: Whitespace changes.
2014-06-18 10:14:56 +01:00
Samuel Bronson 6a83deeaa8 Brown paper bag: left out part of the ChangeLog entry ... 2014-06-18 00:26:46 -04:00
Samuel Bronson 2afe7d509a * MAINTAINERS: Update Roland McGrath's email address.
Thanks to Sergio Durigan Junior for pointing out that he left
Red Hat a while ago, and giving me a current address.
2014-06-18 00:12:57 -04:00
Tom Tromey 3bca49eec2 remove redundant savestring declaration
I happened to notice that savestring is still declared in utils.h,
despite the fact that it was moved to common/ a while back.  This
patch removes the redundant declaration.  Tested by rebuilding.  I'm
committing this as obvious.

2014-06-17  Tom Tromey  <tromey@redhat.com>

	* utils.h (savestring): Remove declaration.
2014-06-17 12:57:06 -06:00
Tom Tromey 6e366df19d use make_cleanup_freeargv
This replaces a function cast with a call to make_cleanup_freeargv.

I'm checking this in as obvious.

2014-06-17  Tom Tromey  <tromey@redhat.com>

	* remote.c (extended_remote_run): Use make_cleanup_freeargv.
2014-06-17 11:43:21 -06:00
Yao Qi 0fc0599720 Different outputs affected by hosts
We find the following fails in gdb test on mingw host.

FAIL: gdb.base/wchar.exp: print repeat
FAIL: gdb.base/wchar.exp: print repeat_p
FAIL: gdb.base/wchar.exp: print repeat (print null on)
FAIL: gdb.base/wchar.exp: print repeat (print elements 3)
FAIL: gdb.base/wchar.exp: print repeat_p (print elements 3)

print repeat^M
$7 = L"A", '¢' <repeats 21 times>, "B", '\000' <repeats 104 times>^M
(gdb) FAIL: gdb.base/wchar.exp: print repeat

the \242 is expected in the test but cent sign is displayed.

In valprint.c:print_wchar, wchar_printable is called to determine
whether a wchar is printable.  wchar_printable calls iswprint but
the iswprint's return value depends on LC_CTYPE setting of locale [1, 2].
The output may vary with different locale settings and OS.  IMO, '¢'
(cent sign) is a correct output on Windows.

[1] http://pubs.opengroup.org/onlinepubs/009604499/functions/iswprint.html
[2] http://msdn.microsoft.com/en-us/library/ewx8s4kw.aspx

This patch is set $cent to cent sign if the GDB is running on a
Windows host.

gdb/testsuite:

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

	* gdb.base/wchar.exp: Set $cent to \u00A2 if "host-charset" is
	CP1252.
2014-06-17 19:35:32 +08:00
Luis Machado 70795c525e In a couple functions (type_update_when_use_rtti_test and
skip_type_update_when_not_use_rtti_test) the testcase assumes an
uninitialized object has a specific type. In particular, 'ptr' and
's'.

In reality the compiler is free to do what it wants with that
uninitialized variable, even initialize it beforehand with the future
assignment's value.  This is exactly what happens on some targets.

ptr should have type 'Base *', but it really has type 'Derived *'
because it is already initialized (earlier) by the compiler. The same
thing happens to 's'.

The following patch addresses this by explicitly initializing those
variables so the compiler doesn't optimize their assignments and GDB
can print their correct values.

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

	* gdb.mi/mi-var-rtti.cc (type_update_when_use_rtti_test):
	Initialize ptr and S explicitly.
	(skip_type_update_when_not_use_rtti_test): Likewise.
2014-06-17 10:42:23 +01:00
Keith Seitz 6be47f0c48 Fix for PR mi/15863
If an MI client creates a varobj and attempts to update the root
/before/ the inferior is started, gdb will throw an internal error:

(gdb)
-var-create * - batch_flag
^done,name="var1",numchild="0",value="0",type="int",has_more="0"
(gdb)
-var-update var1
^done,changelist=[]
(gdb)
-var-update *
~"../../src/gdb/thread.c:628: internal-error: is_thread_state: Assertion `tp' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? "
~"(y or n) "

The function that handles the varobj update in the failing case,
mi_cmd_var_udpate_iter, checks if the thread/inferior is stopped before
attempting to update the varobj. It calls is_stopped (inferior_ptid)
which calls is_thread_state:

    tp = find_thread_ptid (ptid);
    gdb_assert (tp);

When there is no inferior, ptid is null_ptid, and find_thread_ptid (null_ptid)
returns NULL and the assertion is triggered.

This patch changes mi_cmd_var_update_iter to behave the same way
"-var-update var1" does: by calling the thread "stopped" if
there is no inferior (and thereby calling varobj_update_one).

ChangeLog
2014-06-16  Keith Seitz  <keiths@redhat.com>

	PR mi/15863
	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Do not attempt
	to update the varobj if inferior_ptid is null_ptid.

testsuite/ChangeLog
2014-06-16  Keith Seitz  <keiths@redhat.com>

	PR mi/15863
	* gdb.mi/mi-var-cmd.exp: Add test for -var-update before
	the inferior is started.
2014-06-16 11:38:19 -07:00
Tom Tromey 7bc112c1b9 constify to_info_proc and friends
This makes a parameter of to_info_proc const and then fixes up some
fallout, including parameters in a couple of gdbarch methods.

I could not test the procfs.c change.  I verified it by inspection.
If this causes an error here, it will be trivial to fix.

2014-06-16  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_info_proc>: Make parameter
	const.
	(target_info_proc): Update.
	* target.c (target_info_proc): Make "args" const.
	* procfs.c (procfs_info_proc): Update.
	* linux-tdep.c (linux_info_proc): Update.
	(linux_core_info_proc_mappings): Make "args" const.
	(linux_core_info_proc): Update.
	* gdbarch.sh (info_proc, core_info_proc): Make "args" const.
	* gdbarch.c: Rebuild.
	* gdbarch.h: Rebuild.
	* corelow.c (core_info_proc): Update.
2014-06-16 10:29:17 -06:00
Tom Tromey fee354eeef constify to_disconnect
This constifies an parameter of to_disconnect and updates
target_disconnect as well.

2014-06-16  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_disconnect>: Make parameter
	const.
	(target_disconnect): Update.
	* target.c (target_disconnect): Make "args" const.
	* target-delegates.c: Rebuild.
	* remote.c (remote_disconnect): Update.
	* record.h (record_disconnect): Update.
	* record.c (record_disconnect): Update.
	* inf-child.c (inf_child_disconnect): Update.
2014-06-16 10:29:17 -06:00
Tom Tromey a30bf1f15c constify to_rcmd
This makes the "command" parameter of the to_rcmd target method const.

2014-06-16  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_rcmd>: Make "command" const.
	* target.c (debug_to_rcmd, default_rcmd): Update.
	* target-delegates.c: Rebuild.
	* remote.c (remote_rcmd): Update.
	* monitor.c (monitor_rcmd): Update.
2014-06-16 10:29:17 -06:00
Pedro Alves d03de42190 "$ gdb PROGRAM" vs "(gdb) file PROGRAM" difference; warn on failure to remove breakpoint.
Turns out there's a difference between loading the program with "gdb
PROGRAM", vs loading it with "(gdb) file PROGRAM".  The latter results
in the objfile ending up with OBJF_USERLOADED set, while not with the
former.  (That difference seems bogus, but still that's not the point
of this patch.  We can revisit that afterwards.)

The new code that suppresses breakpoint removal errors for
add-symbol-file objects ends up being too greedy:

      /* In some cases, we might not be able to remove a breakpoint in
         a shared library that has already been removed, but we have
         not yet processed the shlib unload event.  Similarly for an
         unloaded add-symbol-file object - the user might not yet have
         had the chance to remove-symbol-file it.  shlib_disabled will
         be set if the library/object has already been removed, but
         the breakpoint hasn't been uninserted yet, e.g., after
         "nosharedlibrary" or "remove-symbol-file" with breakpoints
         always-inserted mode.  */
      if (val
          && (bl->loc_type == bp_loc_software_breakpoint
              && (bl->shlib_disabled
                  || solib_name_from_address (bl->pspace, bl->address)
                  || userloaded_objfile_contains_address_p (bl->pspace,
                                                            bl->address))))
        val = 0;

as it turns out that OBJF_USERLOADED can be set for objfiles loaded by
some other means not add-symbol-file.  In this case, symbol-file (or
"file", which is really just "exec-file"+"symbol-file").

Recall that add-symbol-file is documented as:

 (gdb) help add-symbol-file
 Load symbols from FILE, assuming FILE has been dynamically loaded.
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

And it's the "dynamically loaded" aspect that the breakpoint.c code
cares about.  So make add-symbol-file set OBJF_SHARED on its objfiles
too, and tweak the breakpoint.c code to look for OBJF_SHARED instead
of OBJF_USERLOADED.

This restores back the missing breakpoint removal warning when we let
sss-bp-on-user-bp-2.exp run on native GNU/Linux
(https://sourceware.org/ml/gdb-patches/2014-06/msg00335.html):

 (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: define stepi_del_break
 stepi_del_break
 warning: Error removing breakpoint 3
 (gdb) FAIL: gdb.base/sss-bp-on-user-bp-2.exp: stepi_del_break

I say "restores" because this was GDB's behavior in 7.7 and earlier.

And, likewise, "file" with no arguments only started turning
breakpoints set in the main executable to "<pending>" with the
remote-symbol-file patch (63644780).  The old behavior is now
restored, and we break-unload-file.exp test now exercizes both "gdb;
file PROGRAM" and "gdb PROGRAM".

gdb/
2014-06-16  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (insert_bp_location, remove_breakpoint_1): Adjust.
	(disable_breakpoints_in_freed_objfile): Skip objfiles that don't
	have OBJF_SHARED set.
	* objfiles.c (userloaded_objfile_contains_address_p): Rename to...
	(shared_objfile_contains_address_p): ... this.  Check OBJF_SHARED
	instead of OBJF_USERLOADED.
	* objfiles.h (OBJF_SHARED): Update comment.
	(userloaded_objfile_contains_address_p): Rename to ...
	(shared_objfile_contains_address_p): ... this, and update
	comments.
	* symfile.c (add_symbol_file_command): Also set OBJF_SHARED in the
	new objfile.
	(remove_symbol_file_command): Skip objfiles that don't have
	OBJF_SHARED set.

gdb/testsuite/
2014-06-16  Pedro Alves  <palves@redhat.com>

	* gdb.base/break-main-file-remove-fail.c: New file.
	* gdb.base/break-main-file-remove-fail.exp: New file.
	* gdb.base/break-unload-file.exp: Use build_executable instead of
	prepare_for_testing.
	(test_break): New parameter "initial_load".  Handle it.
	(top level): Add initial_load cmdline/file axis.
2014-06-16 15:38:13 +01:00
Tom Tromey 99f4262f2c fix incorrect comments in minsyms.h
minsyms.h incorrectly claims that a couple of functions call
prim_record_minimal_symbol_full with COPY_NAME=0 -- but actually they
pass 1.  Passing 1 is the correct behavior, so this patch fixes the
documentation.

I'm checking this in as obvious.

2014-06-16  Tom Tromey  <tromey@redhat.com>

	* minsyms.h (prim_record_minimal_symbol)
	(prim_record_minimal_symbol_and_info): Update comments.
2014-06-16 07:53:36 -06:00
Eli Zaretskii 97d66cc602 Include --with-guile in 'show configuration's output.
* top.c (print_gdb_configuration) [HAVE_GUILE]: Print --with-guile
	or --without-guile, according to how GDB was built.
2014-06-14 20:54:16 +03:00
Tom Tromey 635c7e8a05 make calls to help_list use enumerator
Currently there are many calls to help_list that pass the constant -1
as the "class" value.  However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.

This patch fixes the error everywhere it occurs in the gdb sources.

Tested by rebuilding.

2014-06-13  Tom Tromey  <tromey@redhat.com>

	* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
	to help_list.
	* guile/guile.c (info_guile_command): Pass all_commands, not -1,
	to help_list.
	* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
	help_list.
	* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
	help_list.Pass all_commands, not -1, to help_list.
	* cli/cli-dump.c (dump_command, append_command)
	(srec_dump_command, ihex_dump_command, tekhex_dump_command)
	(binary_dump_command, binary_append_command): Pass all_commands,
	not -1, to help_list.
	* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
	-1, to help_list.
	* valprint.c (set_print, set_print_raw): Pass all_commands, not
	-1, to help_list.
	* typeprint.c (set_print_type): Pass all_commands, not -1, to
	help_list.
	* top.c (set_history): Pass all_commands, not -1, to help_list.
	* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
	all_commands, not -1, to help_list.
	* symfile.c (overlay_command): Pass all_commands, not -1, to
	help_list.
	* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
	help_list.
	* serial.c (serial_set_cmd): Pass all_commands, not -1, to
	help_list.
	* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
	-1, to help_list.
	* remote.c (remote_command, set_remote_cmd): Pass all_commands,
	not -1, to help_list.
	* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
	not -1, to help_list.
	* maint.c (maintenance_command, maintenance_info_command)
	(maintenance_print_command, maintenance_set_cmd): Pass
	all_commands, not -1, to help_list.
	* macrocmd.c (macro_command): Pass all_commands, not -1, to
	help_list.
	* language.c (set_check): Pass all_commands, not -1, to help_list.
	* infcmd.c (unset_command): Pass all_commands, not -1, to
	help_list.
	* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
	help_list.
	* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
	help_list.
	* dcache.c (set_dcache_command): Pass all_commands, not -1, to
	help_list.
	* breakpoint.c (save_command): Pass all_commands, not -1, to
	help_list.
	* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
	all_commands, not -1, to help_list.
2014-06-13 09:29:19 -06:00
Pierre Langlois b94ade4284 Invalidate a register in cache when a remote target failed to write it.
As shown by the bug report, GDB crashes when the remote target was unable to
write to a register (the program counter) with the 'P' packet. This was reported
for AVR but can be reproduced on any architecture with a gdbserver that fails to
handle a 'P' packet.

Issue
=====

This GDB session was done with a custom gdbserver patched to send an error
packet when trying to set the program counter with a 'P' packet:

~~~
(gdb) file Debug/ATMega2560-simple-program.elf
Reading symbols from Debug/ATMega2560-simple-program.elf...done.
(gdb) target remote :51000
Remote debugging using :51000
0x00000000 in __vectors ()
(gdb) load
Loading section .text, size 0x1fc lma 0x0
Start address 0x0, load size 508
Transfer rate: 248 KB/sec, 169 bytes/write.
(gdb) b main
Breakpoint 1 at 0x164: file .././ATMega2560-simple-program.c, line 39.
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
main () at .././ATMega2560-simple-program.c:42
42		DDRD |= LED0_MASK;// | LED1_MASK;
(gdb) info line 43
Line 43 of ".././ATMega2560-simple-program.c" is at address 0x178 <main+40> but contains no code.
(gdb) set $pc=0x178
Could not write register "PC2"; remote failure reply 'E00'
(gdb) info registers pc
pc             0x178	0x178 <main+40>
(gdb) s
../../unisrc-mainline/gdb/infrun.c:1978: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
../../unisrc-mainline/gdb/infrun.c:1978: internal-error: resume: Assertion `pc_in_thread_step_range (pc, tp)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n)
~~~

We can see that even though GDB reports that writing to the register failed, the
register cache was updated:

~~~
(gdb) set $pc=0x178
Could not write register "PC2"; remote failure reply 'E00'
(gdb) info registers pc
pc             0x178	0x178 <main+40>
~~~

The root of the problem is of course in the gdbserver but I thought GDB should
keep a register cache consistent with the hardware even in case of a failure.

Changes
=======

This patch adds routines to add a regcache_invalidate cleanup to the current
chain.

We can then register one before calling target_store_registers. This way if the
target throws an error, the register we wanted to write to will be invalidated
in cache. If target_store_registers succeeds, we can discard the new cleanup.

2014-06-12  Pierre Langlois  <pierre.langlois@embecosm.com>

	* regcache.c (struct register_to_invalidate): New structure.
	(do_register_invalidate, make_cleanup_regcache_invalidate): New
	functions.
	(regcache_raw_write): Call make_cleanup_regcache_invalidate.
2014-06-13 10:57:12 +01:00
Tom Tromey f9d1eeed58 delete gdbserver's freeargv
gdbserver defines freeargv, but it is now trivial to just use the one
in libiberty.

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

	* utils.c (freeargv): Remove.
2014-06-12 14:35:49 -06:00
Tom Tromey 0b04e52316 link gdbserver against libiberty
This builds a libiberty just for gdbserver and arranges for gdbserver
to use it.  I've tripped across the lack of libiberty in gdbserver at
least once, and I have seen other threads where it would have been
useful.

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

	* debug.c (debug_printf): Remove HAVE_GETTIMEOFDAY checks.
	* server.c (monitor_show_help): Remove HAVE_GETTIMEOFDAY check.
	(parse_debug_format_options): Likewise.
	(gdbserver_usage): Likewise.
	* Makefile.in (LIBIBERTY_BUILDDIR, LIBIBERTY): New variables.
	(SUBDIRS, REQUIRED_SUBDIRS): Add libiberty.
	(gdbserver$(EXEEXT), gdbreplay$(EXEEXT)): Depend on and link
	against libiberty.
	($(LIBGNU)): Depend on libiberty.
	(all-lib): Recurse into all subdirs.
	(install-only): Invoke "install" target in subdirs.
	(vasprintf.o, vsnprintf.o, safe-ctype.o, lbasename.o): Remove
	targets.
	* configure: Rebuild.
	* configure.ac: Add ACX_CONFIGURE_DIR for libiberty.  Don't check
	for vasprintf, vsnprintf, or gettimeofday.
	* configure.srv: Don't add safe-ctype.o or lbasename.o to
	srv_tgtobj.
2014-06-12 14:35:47 -06:00
Tom Tromey f9579b9902 don't use directory in test name
I noticed that a few tests in completion.exp put the directory name
into the name of the resulting test.  While the directory name is
relative, this still makes for spurious differences depending on
whether the test was run in serial or parallel mode.

This patch fixes the problem.  I'm checking it in.

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

	* gdb.base/completion.exp: Don't use directory name in test.
2014-06-12 12:09:21 -06:00
Pedro Alves b4b01d36ac Move ChangeLog entry to proper place.
gdb/
2014-06-09  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (linux_child_follow_fork): Initialize status with
	W_STOPCODE (0) instead of 0.  Remove shodowing 'status' local from
	inner block.  Only pass the signal to PTRACE_DETACH if in pass
	state.
2014-06-12 18:47:54 +01:00
Yao Qi 31f628ae8f Use varobj_is_dynamic_p more widely
Use varobj_is_dynamic_p more widely so that the callers of
varobj_is_dynamic_p are unchanged when we add available-children-only
stuff in varobj_is_dynamic_p.

gdb:

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

	* varobj.c (varobj_get_num_children): Call
	varobj_is_dynamic_p.
	(varobj_list_children): Likewise.
	(varobj_update): Likewise.  Update comments.
2014-06-12 15:27:42 +08:00
Yao Qi cde5ef40f8 Rename varobj_pretty_printed_p to varobj_is_dynamic_p
We think varobj with --available-children-only behaves like a dynamic
varobj, so dyanmic varobj is not pretty-printer specific.  We rename
varobj_pretty_printed_p to varobj_is_dynamic_p, so that we can handle
available-children-only checking in varobj_is_dynamic_p in the next
patch.

gdb:

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

	* varobj.c (varobj_pretty_printed_p): Rename to ...
	(varobj_is_dynamic_p): ... this.  New function.
	* varobj.h (varobj_pretty_printed_p): Remove declaration.
	(varobj_is_dynamic_p): Declare.
	* mi/mi-cmd-var.c (print_varobj): All callers updated.
	(mi_print_value_p, varobj_update_one): Likewise.
2014-06-12 15:27:31 +08:00
Yao Qi 576ea0910f Remove #if HAVE_PYTHON
This patch removes some unnecessary "#if HAVE_PYTHON" so that more
code is generalized.

gdb:

2014-06-12  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* varobj.c: Remove "#if HAVE_PYTHON" and "#endif".
	(varobj_get_iterator): Wrap up code for pretty-printer by
	"#if HAVE_PYTHON" and "#endif".
	(update_dynamic_varobj_children): Likewise.
2014-06-12 15:27:26 +08:00
Yao Qi 827f100cee Iterate over 'struct varobj_item' instead of PyObject
In previous patch, "saved_item" is still a PyOjbect and iteration is
still performed over PyObject.  This patch continues to decouple
iteration from python code, so it changes its type to "struct
varobj_item *", so that the iterator itself is independent of python.

 V2:
 - Call varobj_delete_iter in free_variable.
 - Fix changelog entries.
 - Use XNEW.

 V3:
 - Return NULL early in py_varobj_iter_next if gdb_python_initialized
   is false.

gdb:

2014-06-12  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* python/py-varobj.c (py_varobj_iter_next): Return NULL if
	gdb_python_initialized is false.  Move some code from varobj.c.
	* varobj-iter.h (struct varobj_item): Moved from varobj.c.
	* varobj.c: Move "varobj-iter.h" inclusion earlier.
	(struct varobj_item): Moved to varobj-iter.h".
	(varobj_clear_saved_item): New function.
	(update_dynamic_varobj_children): Move python-related code to
	py-varobj.c.
	(free_variable): Call varobj_clear_saved_item and
	varobj_iter_delete.
2014-06-12 15:27:19 +08:00
Yao Qi e525021603 Generalize varobj iterator
This patch generalizes varobj iterator, in a python-independent way.
Note varobj_item is still a typedef of PyObject, we can only focus on
API changes, and leave the data type changes to the next patch.  As a
result, we include "varobj-iter.h" after the typedef of PyObject in
varobj.c, but it is an intermediate state.  Finally, varobj-iter.h is
independent of PyObject.

This change is helpful to move some python-related code out of
varobj.c.

 V2:
  - Fix a missing cleanup.
  - Fix typos.
  - Use XNEW.
  - Check against NULL explicitly.
  - Update copyright year for new added files.

 V3:
  - Call PyGILState_Ensure before Py_XDECREF.
  - Use CPYCHECKER_STEALS_REFERENCE_TO_ARG.
  - Code indentation.

 V4:
  - use varobj_ensure_python_env instead of PyGILState_Ensure.

gdb:

2014-06-12  Pedro Alves  <pedro@codesourcery.com>
	    Yao Qi  <yao@codesourcery.com>

	* Makefile.in (SUBDIR_PYTHON_OBS): Add "py-varobj.o".
	(SUBDIR_PYTHON_SRCS): Add "python/py-varobj.c".
	(HFILES_NO_SRCDIR): Add "varobj-iter.h".
	(py-varobj.o): New rule.
	* python/py-varobj.c: New file.
	* python/python-internal.h (py_varobj_get_iterator): Declare.
	* varobj-iter.h: New file.
	* varobj.c: Include "varobj-iter.h"
	(struct varobj) <child_iter>: Change its type from "PyObject *"
	to "struct varobj_iter *".
	<saved_item>: Likewise.
	[HAVE_PYTHON] (varobj_ensure_python_env): Make it extern.
	[HAVE_PYTHON] (varobj_get_iterator): New function.
	(update_dynamic_varobj_children) [HAVE_PYTHON]: Move
	python-specific code to python/py-varobj.c.
	(install_visualizer): Call varobj_iter_delete instead of
	Py_XDECREF.
	* varobj.h (varobj_ensure_python_env): Declare.
2014-06-12 15:27:15 +08:00
Yao Qi 5a2e0d6e89 Use 'struct varobj_item' to represent name and value pair
Hi,
name and value pair is widely used in varobj.c.  This patch is to add
a new struct varobj_item to represent them, so that the number of
function arguments can be reduced.  Finally, the iteration is done on
'struct varobj_item' instead of PyObject after this patch series.

 V2:
 - Fix changelog entry.
 - Fix one grammatical mistake.

gdb:

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

	* varobj.c (struct varobj_item): New structure.
	(create_child_with_value): Update declaration.
	(varobj_add_child): Replace arguments 'name' and 'value' with
	'item'.  All callers updated.
	(install_dynamic_child): Likewise.
	(update_dynamic_varobj_children): Likewise.
	(varobj_add_child): Likewise.
	(create_child_with_value): Likewise.
2014-06-12 15:27:09 +08:00
Joel Brobecker 919b9a9377 Update NEWS post GDB 7.8 branch creation.
gdb/ChangeLog:

	* NEWS: Create a new section for the next release branch.
	Rename the section of the current branch, now that it has
	been cut.
2014-06-11 18:52:29 +02:00
Joel Brobecker 71a55bdf7d Bump version to 7.8.50.DATE-cvs.
Now that the GDB 7.8 branch has been created, we can
bump the version number.

gdb/ChangeLog:

	GDB 7.8 branch created (173373c6f6):
	* version.in: Bump version to 7.8.50.DATE-cvs.
2014-06-11 18:37:55 +02:00
Pedro Alves 364fe1f722 PR remote/17028: GDB+GDBserver hangs on Windows
Since target-async was turned on by default, debugging on Windows
using GDB+GDBserver sometimes hangs while waiting for a RSP reply.

The problem is a race in the gdb_select machinery.

This is what we see for a faulty next on the GDB side:

    (gdb) n
    infrun: clear_proceed_status_thread (Thread 4424)
    infrun: proceed (addr=0xffffffff, signal=GDB_SIGNAL_DEFAULT, step=1)
    (...)
    infrun: resume (step=1, signal=GDB_SIGNAL_0), ...
    Sending packet: $vCont;s:1148;c#5e...
    *hang*

At this point, attaching a debugger to the hanging GDB confirms that
it is blocked, waiting for a socket event:

    #6  0x757841d8 in WaitForMultipleObjects ()
       from C:\Windows\syswow64\kernel32.dll
    #7  0x004708e7 in gdb_select (n=469, readfds=0x88ca50 <gdb_notifier+784>,
        writefds=0x88cb54 <gdb_notifier+1044>,
        exceptfds=0x88cc58 <gdb_notifier+1304>, timeout=0x0)
        at /[...]/gdb/mingw-hdep.c:172
    #8  0x00527926 in gdb_wait_for_event (block=1)
        at /[...]/gdb/event-loop.c:831
    #9  0x00526ff1 in gdb_do_one_event ()
        at /[...]/gdb/event-loop.c:403

However, on the GDBserver side, we see that GDBserver already sent a
T05 packet reply:

    gdbserver: kernel event EXCEPTION_DEBUG_EVENT for pid=4968 tid=1148
    EXCEPTION_SINGLE_STEP
    Child Stopped with signal = 5
    Writing resume reply for LWP 4968.4424:1
    DEBUG: write_prim ($T0505:c8fe2800;04:a0fe2800;08:38164000;thread:1148;#f0)
           -> 55

To recap, on Windows, 'select' only works with sockets, so we have a
wrapper, gdb_select, that uses the GDB serial abstraction to handle
sockets, consoles, pipes, and serial ports.  Each serial descriptor
has a thread associated (we call those the select threads), and those
threads communicate with the main thread by means of standard Windows
events.

It basically goes like this: gdb_select first loops through all fds of
interest, calling their wait_handle hooks, which returns an event that
WaitForMultipleObjects can wait on.  gdb_select then blocks in
WaitForMultipleObjects with all those event handles.  The wait_handle
hook is responsible for arranging for the returned event to become set
once data is available.  This is done by setting the descriptor's
helper thread running, which itself knows how to wait for data from
the type of handle it manages (sockets, pipes, consoles, files, etc.).
Once data arrives, the select thread sets the corresponding event
which unblocks WaitForMultipleObjects within gdb_select.  However, the
wait_handle hook can also apply an optimization: if data is already
pending, then there's no need to set the thread running, and the
descriptors event can be set immediately.  It's around this latter
aspect that lies the bug/race.

Adding some ad hoc debug logs to ser-mingw.c and mingw-hdep.c, we see
the following sequence of events, right after sending
"$vCont;s:1148;c#5e".  Thread 1 is the main thread, and thread 2 is
the socket's helper/select thread.  gdb_select was only passed one
descriptor to wait on, the remote target's socket.
net_windows_select_thread is the entry point of the select threads for
sockets.

 #1 - thread 1: gdb_select: enter
 #2 - thread 2: net_windows_select_thread: WaitForMultipleObjects blocking

gdb_select walked over the wait_handle hooks, and woke up the socket's
helper thread.  The helper thread is now blocked waiting for socket
events.

 #3 - thread 1: gdb_select: WaitForMultipleObjects polling (timeout=0ms)
 #4 - thread 1: gdb_select: WaitForMultipleObjects returned 102 (WAIT_TIMEOUT)

There was no pending data available yet, and gdb_select was passed
timeout==0ms, and so WaitForMultipleObjects times out immediately.

 #5 - thread 2: net_windows_select_thread: WaitForMultipleObjects returned 1

Just afterwards, socket data arrives, and thread 2 wakes up.  Thread 2
calls WSAEnumNetworkEvents, which clears state->sock_event, and marks
the serial's read_event event, telling the main thread that data is
available.

 #6 - thread 1: gdb_select: call serial_done_wait_handle on each serial

gdb_select stops all the helper/select threads.

 #7 - thread 1: gdb_select: return 0 (WAIT_TIMEOUT)

gdb_select in the main thread returns to the caller.

Note that at this point, data is pending on the socket, the serial's
read_event is set, but the socket's sock_event event is not set, until
_further_ data arrives.

Now GDB does its thing and goes back to the event loop.  That calls
gdb_select, but with timeout==INFINITE.

Again, gdb_select calls the socket serial's wait_handle hook.  It
first clears its events, starting from a clean slate:

  ResetEvent (state->base.read_event);
  ResetEvent (state->base.except_event);
  ResetEvent (state->base.stop_select);

That cleared read_event, which was previously set in #5 above.  And
then it checks for pending events, in the sock_event event:

  /* Check any pending events.  This both avoids starting the thread
     unnecessarily, and handles stray FD_READ events (see below).  */
  if (WaitForSingleObject (state->sock_event, 0) == WAIT_OBJECT_0)
    {

That also fails because state->sock_event was cleared in #5 too...

So the wait_handle hook erroneously decides that it needs to start the
helper thread to wait for input:

 #8 - thread 2: net_windows_select_thread: WaitForMultipleObjects blocking
 #9 - thread 1: gdb_select: WaitForMultipleObjects blocking (INFINITE)

But, GDBserver already sent all it had to send, so both threads waits
forever...

At first I thought that net_windows_wait_handle shouldn't be resetting
state->base.read_event or state->base.except_event, but looking
deeper, the pipe and console wait_handle hooks reset all events too.
It actually makes sense that way -- consuming an event from different
threads is bad practice, and, we should always be able to query
pending state without looking at the state->sock_event from within
net_windows_wait_handle.  The end result is much simpler, and makes
net_windows_select_thread look a lot like console_select_thread,
actually.

gdb/
2014-06-11  Pedro Alves  <palves@redhat.com>

	PR remote/17028
	* ser-mingw.c (net_windows_socket_check_pending): New function.
	(net_windows_select_thread): Ignore spurious wakeups.  Use
	net_windows_socket_check_pending.
	(net_windows_wait_handle): Check for pending events with
	ioctlsocket, through net_windows_socket_check_pending, instead of
	checking the socket's event.
2014-06-11 11:04:31 +01:00
Siva Chandra 5a6c770930 Wrap PyObject_Get/HasAttrString in a function with second arg having const qualifier.
This is done to avoid errors when compiled with -Werror against Python-2.4
which did not have the const qualifier for the second argument of these
functions.

gdb/
	* python/python-internal.h (gdb_PyObject_GetAttrString)
	(gdb_PyObject_HasAttrString): New inline function definitions.
	* py-value.c (get_field_flag): Remove the now unnecessary cast to
	char * of the second argument to PyObject_GetAttrString.
2014-06-10 11:52:12 -07:00
Joel Brobecker 0e58ee40a2 thinko in serial.c::serial_write debug trace
I noticed that, when using 'set debug serial 1', the "write" traces
would always be NUL characters:

    [
    w \x00][\x00][\x00][\x00][\x00][etc]

This is due to a small thinko in the loop that output each character,
where we accidently used the loop boundary instead of the loop index
to index the character to be printed.

After this patch is applied, the output now becomes:

    [
    w $][v][C][o][n][t][?][#][4][9]

gdb/ChangeLog:

	* serial.c (serial_write): Fix index of character to be printed
	in call to serial_logchar when serial debug traces are enabled.
2014-06-10 11:50:06 +02:00
Joel Brobecker d190df30a1 gdbtypes.resolve_dynamic_range: Add function description.
gdb/ChangeLog:

        * gdbtypes (resolve_dynamic_range): Add function description.
2014-06-10 10:51:37 +02:00
Siva Chandra dd5d5494f4 Add space before the opening parenthesis in function descriptions.
gdb/doc
	* python.texi (Xmethod API): Add space before the opening
	parenthesis in function descriptions.
2014-06-09 07:19:28 -07:00
Pedro Alves 9caaaa8397 Fix a bunch of fork related regressions.
I'm seeing a ton of new FAILs in fork-related tests.  Like, these and
many more:

 +FAIL: gdb.base/disp-step-syscall.exp: vfork: continue to vfork (2nd time) (timeout)
 +FAIL: gdb.base/disp-step-syscall.exp: vfork: display/i $pc (timeout)
 ...
 -PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step
 +FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, through step: step (timeout)
 -PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp
 +FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, to bp: continue to bp (timeout)
  ...
  FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: breakpoint (A) after the first fork (timeout)
  FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint A after the first fork (timeout)
  FAIL: gdb.base/fileio.exp: System(3) call (timeout)
  FAIL: gdb.threads/watchpoint-fork.exp: parent: multithreaded: watchpoint B after the first fork (timeout)
 -PASS: gdb.base/multi-forks.exp: run to exit 2
 +FAIL: gdb.base/multi-forks.exp: run to exit 2 (timeout)
  ...
  PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (hw)
 -PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw)
 +FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (hw) (timeout)
  PASS: gdb.base/watch-vfork.exp: Watchpoint on global variable (sw)
 -PASS: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw)
 +FAIL: gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout)

Three issues with
https://sourceware.org/ml/gdb-patches/2014-06/msg00348.html
(c077881a).

 - The inner 'status' local is shadowing the outer 'status' local,
   thus PTRACE_DETACH is never seeing the status it intends to pass on
   the inferior.

 - With that fixed, we then try to pass down the SIGTRAP that results
   from the step to the inferior.  Need to filter out signals that are
   in nopass state.

 - For software single-step archs, the current code is equivalent to:

      int status = 0;
      if (WIFSTOPPED (status))
        ptrace (PTRACE_DETACH, child_pid, 0, WSTOPSIG (status));

   ... and status == 0 is WIFEXITED, not WIFSTOPPED, so we're never
   detaching.

gdb/
2014-06-09  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (linux_child_follow_fork): Initialize status with
	W_STOPCODE (0) instead of 0.  Remove shodowing 'status' local from
	inner block.  Only pass the signal to PTRACE_DETACH if in pass
	state.
2014-06-09 14:53:51 +01:00
Gary Benson 3657956bf8 Separate out ANSI-standard signals
This commit reorders various pieces of code to separate ANSI-standard
signals from other signals that need checking.  Comments are added to
document this, and to document the ordering of the signals.

gdb/
2014-06-09  Gary Benson  <gbenson@redhat.com>

	* common/signals.c (gdb_signal_from_host): Reorder to separate
	the always-available ANSI-standard signals from the signals that
	require checking.
	(do_gdb_signal_to_host): Likewise.
	* proc-events.c (signal_table): Likewise.

gdb/testsuite/
2014-06-09  Gary Benson  <gbenson@redhat.com>

	* gdb.base/sigall.c [Functions to send signals]: Reorder to
	separate the always-available ANSI-standard signals from the
	signals that require checking.
	(main): Likewise.
	* gdb.reverse/sigall-reverse.c [Functions to send signals]:
	Likewise.
	(main): Likewise.
2014-06-09 10:34:33 +01:00
Hui Zhu c077881afa Fix gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw) (timeout) with Linux 2.6.32 and older version
https://sourceware.org/ml/gdb-patches/2014-04/msg00047.html

Got gdb.base/watch-vfork.exp: Watchpoint triggers after vfork (sw)
(timeout) with Linux 2.6.32 and older version.

The rootcause is after the test use "set can-use-hw-watchpoints 0" let GDB
doesn't use hardware breakpoint and set a watchpoint on "global", GDB
continue will keep single step inside function "vfork".
The Linux 2.6.32 and older version doesn't have commit
6580807da14c423f0d0a708108e6df6ebc8bc83d (get more info please goto
http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=6580807da14c423f0d0a708108e6df6ebc8bc83d).
When the function "vfork" do syscall, the single step flag TIF_SINGLESTEP
will copy to child process.
Then GDB detach it, child process and parent process will be hanged.

So I make a patch that do a single step before detach.  Then TIF_SINGLESTEP
of child process in old Linux kernel will be cleared before detach.
Child process in new Linux kernel will not be affected by this single step.

2014-06-08  Hui Zhu  <hui@codesourcery.com>

	* common/linux-ptrace.c (linux_disable_event_reporting): New
	function.
	* common/linux-ptrace.h (linux_disable_event_reporting): New
	declaration.
	* linux-nat.c (linux_child_follow_fork): Do a single step before
	detach.
2014-06-08 19:14:06 +08:00
Keith Seitz 4186eb54dd Revert patchset for c++/16253: it causes a large performance regression.
See the bug for further information.
2014-06-07 10:40:39 -07:00
Doug Evans 25326a285b fix email address of previous checkins 2014-06-06 16:08:54 -07:00
Doug Evans d2929fdcf0 Add support for guile 2.0.5.
* guile/guile-internal.h (gdbscm_guile_major_version): Declare.
	(gdbscm_guile_minor_version, gdbscm_guile_micro_version): Declare.
	(gdbscm_guile_version_is_at_least): Declare.
	(gdbscm_scm_string_to_int): Declare.
	* guile/guile.c (gdbscm_guile_major_version): New global.
	(gdbscm_guile_minor_version, gdbscm_guile_micro_version): New globals.
	(guile_datadir): New static global.
	(gdbscm_guile_data_directory): New function.
	(initialize_scheme_side): Update.
	(misc_guile_functions): Add guile-data-directory.
	(initialize_gdb_module): Fetch guile version number.
	* guile/lib/gdb.scm: Remove call to add-to-load-path.
	* guile/lib/gdb/init.scm (%initialize!): Ditto.
	* guile/lib/gdb/boot.scm: Use guile-data-directory.
	* guile/scm-exception.c (gdbscm_print_exception_with_stack): Fix
	comments.
	* guile/scm-string.c (gdbscm_scm_string_to_int): New function.
	* guile/scm-utils.c (gdbscm_guile_version_is_at_least): New function.
	* guile/scm-value.c (gdbscm_value_to_string): Only call
	scm_port_conversion_strategy if Guile version >= 2.0.6.

	doc/
	* guile.texi (Guile Configuration): Document guile-data-directory.
2014-06-06 15:57:03 -07:00
Doug Evans 6da01dbef2 * gdb.guile/scm-frame-args.c (foo): Tweak to work with gcc 4.6.3. 2014-06-06 15:41:09 -07:00
Pedro Alves 829155c9ad sss-bp-on-user-bp-2.exp sometimes fails on native GNU/Linux.
I noticed that sss-bp-on-user-bp-2.exp is racy on native GNU/Linux.  I
sometimes still see an int3 in the disassembly:

 (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: set debug target 0
 disassemble test
 Dump of assembler code for function test:
    0x0000000000400590 <+0>:     push   %rbp
    0x0000000000400591 <+1>:     mov    %rsp,%rbp
    0x0000000000400594 <+4>:     nop
 => 0x0000000000400595 <+5>:     int3
    0x0000000000400596 <+6>:     pop    %rbp
    0x0000000000400597 <+7>:     retq
 End of assembler dump.
 (gdb) FAIL: gdb.base/sss-bp-on-user-bp-2.exp: before/after disassembly matches

Enabling infrun/target debug logs, we can see the problem.
Simplified, that's:

 (gdb) PASS: gdb.base/sss-bp-on-user-bp-2.exp: define stepi_del_break
 stepi_del_break
 infrun: clear_proceed_status_thread (process 25311)
 infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 25311] at 0x400594
 LLR: PTRACE_SINGLESTEP process 25311, 0 (resume event thread)
 target_resume (25311, step, 0)
 native:target_xfer_partial (3, (null), 0x0, 0x32dce4c, 0x400595, 1) = 0, 0
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) linux_nat_wait: [process -1], [TARGET_WNOHANG]

0x400595 is the address of the breakpoint, and "= 0" is
TARGET_XFER_EOF.  That's default_memory_remove_breakpoint trying to
remove the breakpoint, but failing.

The problem is that we had just resumed the target and the native
GNU/Linux target can't read memory off of a running thread.  Most of
the time, we get "lucky", because we manage to read memory before the
kernel actually schedules the target to run.

So just give up and skip the test on any target that uses hardware
stepping, not just remote targets.

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

	* gdb.base/sss-bp-on-user-bp-2.exp: Look for target_resume(step)
	in target debug output instead of looking at RSP packets,
	disabling the test on any target that uses hardware stepping.
	Update comments.
2014-06-06 19:59:21 +01:00
Pedro Alves 61c8d22ea3 break-unload-file.exp: Fix typo.
s/is not pending/is pending/

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

	* gdb.base/break-unload-file.exp: Fix typo.
2014-06-06 15:52:24 +01:00
Yao Qi d9a4728770 Restrict the pattern in gdb.base/jit.exp
I see the following fail in some thumb multi-lib in arm-none-linux-gnueabi,

info function jit_function^M
All functions matching regular expression "jit_function":^M
^M
Non-debugging symbols:^M
0x00000790  __real_jit_function_XXXX^M
0x0000079c  __jit_function_XXXX_from_arm^M
0x0000079c  jit_function_0000^M
0x00000790  __real_jit_function_XXXX^M
0x0000079c  __jit_function_XXXX_from_arm^M
0x0000079c  jit_function_0001^M
(gdb) FAIL: gdb.base/jit.exp: one_jit_test-2: info function jit_function

the test expects to see only jit_function_0000 and jit_function_0001

one_jit_test 2 "${hex}  jit_function_0000\[\r\n\]+${hex}  jit_function_0001"

Symbols with the prefix "__real_" or suffix "_from_arm" is generated
by gcc/ld for arm/thumb interworking.

This patch is to restrict the pattern from "jit_function" to
"^jit_function", the output becomes expected.

gdb/testsuite:

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

	* gdb.base/jit.exp (one_jit_test): Restrict the pattern
	from "jit_function" to "^jit_function".
2014-06-06 21:43:26 +08:00
Yao Qi e5e01dbf89 Tweak gdb.base/async.exp
I see two fails in async.exp on arm-none-eabi target:

nexti&^M
(gdb) 0x000001ba        14       x = 5; x = 5;^M
completed.^M
FAIL: gdb.base/async.exp: nexti&
finish&^M
Run till exit from #0  0x000001ba in foo () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:14^M
(gdb) 0x000001e6 in main () at /scratch/yqi/arm-none-eabi-lite/src/gdb-trunk/gdb/testsuite/gdb.base/async.c:32^M
32       y = foo ();^M
Value returned is $1 = 8^M
completed.^M
FAIL: gdb.base/async.exp: finish&

The corresponding test is "test_background "nexti&" "" ".*y = 3.*"",
and it assumes that GDB "nexti" into the next source line.  It is wrong
on arm.  After "nexti", it still stops at the same source line, and it
fails.

When gdb does "finish", if the PC is in the middle of a source line,
the PC address is printed too.  See stack.c:print_frame,

  if (opts.addressprint)
    if (!sal.symtab
	|| frame_show_address (frame, sal)
	|| print_what == LOC_AND_ADDRESS)
      {
	annotate_frame_address ();
	if (pc_p)
	  ui_out_field_core_addr (uiout, "addr", gdbarch, pc);
	else
	  ui_out_field_string (uiout, "addr", "<unavailable>");
	annotate_frame_address_end ();
	ui_out_text (uiout, " in ");
      }

frame_show_address checks whether PC is the middle of a source line.
Since after "nexti", the inferior stops at the middle of a source line,
when we do "finish" the PC address is displayed.

In sum, GDB works well, but test case needs update.  This patch is to
add a statement at the same line to make sure "nexti" doesn't go to
the new line, match the next instruction address in the output and
match the hex address the output of "finish".

gdb/testsuite:

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

	* gdb.base/async.c (foo): Add one statement.
	* gdb.base/async.exp: Get the next instruction address and
	match the output of "nexti" by instruction address.  Match
	the hex address in the output of "finish".
2014-06-06 21:43:20 +08:00
xmj 0a770bb257 update ChangeLog 2014-06-06 17:51:30 +08:00
Gary Benson 73ba372ccf Remove preprocessor conditionals for ANSI-standard signals
The six signals SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV and SIGTERM
are ANSI-standard and thus guaranteed to be available.  This patch
removes all preprocessor conditionals relating to these symbols.

gdb/
2014-06-06  Gary Benson  <gbenson@redhat.com>

	* common/signals.c: Remove preprocessor conditionals for
	always-defined signals SIGINT, SIGILL, SIGABRT, SIGFPE,
	SIGSEGV and SIGTERM.
	* proc-events.c: Likewise.

gdb/testsuite/
2014-06-06  Gary Benson  <gbenson@redhat.com>

	* gdb.base/call-signals.c: Remove preprocessor conditionals
	for always-defined signals SIGINT, SIGILL, SIGABRT, SIGFPE,
	SIGSEGV and SIGTERM.
	* gdb.base/sigall.c: Likewise.
	* gdb.base/unwindonsignal.c: Likewise.
	* gdb.reverse/sigall-reverse.c: Likewise.
2014-06-06 10:32:12 +01:00
xmj adcc0a31cc add -q in help info and doc 2014-06-06 17:28:19 +08:00
Yao Qi 831517df13 Skip hbreak-unmapped.exp if memory at address 0 is readable
hbreak-unmapped.exp assumes that memory at address 0 is unmapped or
unreadable, but on bare metal or uclinux targets, memory at address
0 is readable.  For example, on arm-none-eabi, the vector table base
address is 0x0.

hbreak *0^M
Hardware assisted breakpoint 3 at 0x0: file
/scratch/yqi/arm-none-eabi-lite/obj/cs3-2014.11-999999-arm-none-eabi-i686-pc-linux-gnu/generated/arm-vector.S,
line 25.^M
(gdb) FAIL: gdb.base/hbreak-unmapped.exp: hbreak *0
info break^M
Num     Type           Disp Enb Address    What^M
3       hw breakpoint  keep y   0x00000000
/scratch/yqi/arm-none-eabi-lite/obj/cs3-2014.11-999999-arm-none-eabi-i686-pc-linux-gnu/generated/arm-vector.S:25^M
(gdb) FAIL: gdb.base/hbreak-unmapped.exp: info break shows hw breakpoint
delete $bpnum

This patch is to check whether address 0 is readable via command 'x 0'.
If it is, skip the test.

gdb/testsuite:

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

	* gdb.base/hbreak-unmapped.exp: Read memory at address 0.  If
	readable, skip the test.
2014-06-06 16:57:15 +08:00
Markus Metzger c33b2f1258 symfile, vdso: remove target sections
Target sections added by the add-symbol-file-from-memory command are not
removed when the process exits.  In fact, they are not removed, at all.

This causes GDB to crash in gdb.base/break-interp.exp.

Change the owner of those target sections to the object file generated in
symbol_file_add_from_memory and generalize the free_objfile observer in
symfile.c to remove target sections of any freed object file.
2014-06-06 09:40:02 +02:00
Yao Qi b8b91e982e Fix the race in gdb.threads/staticthreads.exp
The code in gdb.threads/staticthreads.exp about checking the value of
tlsvar in main thread is racy, because when child thread hits
breakpoint, the main thread may not go into pthread_join yet, and
may not be unwind to main.

This patch is to move the line setting breakpoint on after sem_wait,
so that the child thread will hit breakpoint after main thread calls
sem_post.  IOW, when child thread hits breakpoint, the main thread is
in either sem_post or pthread_join.  "up 10" can unwind main thread to
main.

gdb/testsuite:

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

	* gdb.threads/staticthreads.c (thread_function): Move the line
	setting breakpoint on forward.
	* gdb.threads/staticthreads.exp: Update comments.
2014-06-06 09:45:22 +08:00
Ludovic Courtès fb9347707f guile: Type-check the argument to 'history-append!'.
gdb/
2014-06-05  Ludovic Courtès  <ludo@gnu.org>

	* guile/scm-value.c (gdbscm_history_append_x): Use
	'vlscm_get_value_smob_arg_unsafe' instead of
	'vlscm_scm_to_value'.

gdb/testsuite/
2014-06-05  Ludovic Courtès  <ludo@gnu.org>

	* gdb.guile/scm-value.exp (test_value_in_inferior): Add test
	"history-append! type error".
2014-06-06 00:05:18 +02:00
Simon Marchi 6ef284bd18 PR mi/15806: Fix quoting of async events
Original patch:
https://sourceware.org/ml/gdb-patches/2014-04/msg00552.html

New in v2:
* In remote.c:escape_buffer, pass '\\' to fputstrn_unfiltered/printchar to
make sure backslashes are escaped in remote debug output.
* Updated function documentation for printchar.

See updated ChangeLog below.

--------------------

The quoting in whatever goes in the event_channel of MI is little bit broken.

Link for the lazy:
  https://sourceware.org/bugzilla/show_bug.cgi?id=15806

Here is an example of a =library-loaded event with an ill-named directory,
/tmp/how"are\you (the problem is present with every directory on Windows since
it uses backslashes as a path separator). The result will be the following:

=library-loaded,id="/tmp/how"are\\you/libexpat.so.1",...

The " between 'how' and 'are' should be escaped.

Another bad behavior is double escaping in =breakpoint-created, for example:

=breakpoint-created,bkpt={...,fullname="/tmp/how\\"are\\\\you/test.c",...}

The two backslashes before 'how' should be one and the four before 'you' should
be two.

The reason for this is that when sending something to an MI console, escaping
can take place at two different moments (the actual escaping work is always
done in the printchar function):

1. When generating the content, if ui_out_field_* functions are used. Here,
fields are automatically quoted with " and properly escaped. At least
mi_field_string does it, not sure about mi_field_fmt, I need to investigate
further.

2. When gdb_flush is called, to send the data in the buffer of the console to
the actual output (stdout). At this point, mi_console_raw_packet takes the
whole string in the buffer, quotes it, and escapes all occurences of the
quoting character and backslashes. The event_channel does not specify a quoting
character, so quotes are not escaped here, only backslashes.

The problem with =library-loaded is that it does use fprintf_unfiltered, which
doesn't do escaping (so, no #1). When gdb_flush is called, backslashes are
escaped (#2).

The problem with =breakpoint-created is that it first uses ui_out_field_*
functions to generate its output, so backslashes and quotes are escaped there
(#1). backslashes are escaped again in #2, leading to an overdose of
backslashes.

In retrospect, there is no way escaping can be done reliably in
mi_console_raw_packet for data that is already formatted, such as
event_channel. At this point, there is no way to differentiate quotes that
delimit field values from those that should be escaped. In the case of other MI
consoles, it is ok since mi_console_raw_packet receives one big string that
should be quoted and escaped as a whole.

So, first part of the fix: for the MI channels that specify no quoting
character, no escaping at all should be done in mi_console_raw_packet (that's
the change in printchar, thanks to Yuanhui Zhang for this). For those channels,
whoever generates the content is responsible for proper quoting and escaping.
This will fix the =breakpoint-created kind of problem.

Second part of the fix is to make =library-loaded generate content that is
properly escaped. For this, we use ui_out_field_* functions, instead of one big
fprintf_unfiltered. =library-unloaded suffered from the same problem so it is
modified as well. There might be other events that need fixing too, but that's
all I found with a quick scan. Those that use fprintf_unfiltered but whose sole
variable data is a %d are not critical, since it won't generate a " or a \.

Finally, a test has been fixed, as it was expecting an erroneous output.
Otherwise, all other tests that were previously passing still pass (x86-64
linux).

gdb/ChangeLog:

2014-06-02  Simon Marchi  <simon.marchi@ericsson.com>

	PR mi/15806
	* utils.c (printchar): Don't escape at all if quoter is NUL.
	Update function documentation to clarify effect of parameter
	QUOTER.
	* remote.c (escape_buffer): Pass '\\' as the quoter to
	fputstrn_unfiltered.
	* mi/mi-interp.c (mi_solib_loaded): Use ui_out_field_* functions to
	generate the output.
	(mi_solib_unloaded): Same.

gdb/testsuite/ChangeLog:

2014-06-02  Simon Marchi  <simon.marchi@ericsson.com>

	* gdb.mi/mi-breakpoint-changed.exp (test_insert_delete_modify): Fix
	erroneous dprintf expected input.
2014-06-05 17:59:46 -04:00
Joel Brobecker 270c993744 Make it easy to make --disable-werror the default for both binutils and gdb
The goal of this patch is to provide an easy way to make
--disable-werror the default when building binutils, or the parts
of binutils that need to get built when building GDB. In development
mode, we want to continue making -Werror the default with GCC.
But, when making releases, I think we want to make it as easy as
possible for regular users to successfully build from sources.

GDB already has this kind of feature to turn -Werror as well as
the use of the libmcheck library. As GDB Release Manager, I take
advantage of it to turn those off after having cut the branch.
I'd like to be able to do the same for the binutils bits. And
perhaps Tristan will want to do the same for his releases too
(not sure, binutils builders might be a little savvier than GDB
builders).

This patch introduces a new file, called development.sh, which
just sets a variable called $development. In our development branches
(Eg. "master"), it's set to true. But setting it to false would allow
us to change the default behavior of various development-related
features to be turned off; in this case, it turns off the use of
-Werror by default (use --enable-werror to turn it back on).

bfd/ChangeLog:

        * development.sh: New file.
        * warning.m4 (AM_BINUTILS_WARNINGS): Source bfd/development.sh.
        Make -Werror the default with GCC only if DEVELOPMENT is true.
        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add
        $(srcdir)/development.sh.
        * Makefile.in, configure: Regenerate.

binutils/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gas/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gold/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): New.
        * Makefile.in, configure: Regenerate.

gprof/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

ld/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

opcodes/ChangeLog:

        * Makefile.am (CONFIG_STATUS_DEPENDENCIES): Add dependency on
        bfd's development.sh.
        * Makefile.in, configure: Regenerate.

gdb/ChangeLog:

        * development.sh: Delete.
        * Makefile.in (config.status): Adjust dependency on development.sh.
        * configure.ac: Adjust development.sh source call.
        * configure: Regenerate.

gdb/gdbserver/ChangeLog:

        * configure.ac: Adjust development.sh source call.
        * Makefile.in (config.status): Adjust dependency on development.sh.
        * configure: Regenerate.

Tested on x86_64-linux by building two ways: One with DEVELOPMENT
set to true, and one with DEVELOPMENT set to false. In the first
case, I could see the use of -Werror, while it disappeared in
the second case.
2014-06-05 05:47:29 -07:00
Doug Evans a872e241e2 Delete scm-generics.exp.
Support for smobs as goops classes is changing in guile 2.2.
We may eventually switch to using structs instead of smobs,
so remove any claim we support goops or generics for now.

	* gdb.guile/scm-generics.exp: Delete.
2014-06-04 20:01:40 -07:00
Doug Evans 16f691fb2e Split create-breakpoint! into make-breakpoint, register-breakpoint!.
Rename breakpoint-delete! to delete-breakpoint!.

	* guile/scm-breakpoint.c (struct gdbscm_breakpoint_object): New members
	is_scheme_bkpt, spec.
	(bpscm_make_breakpoint_smob): Initialize new members.
	(gdbscm_create_breakpoint_x): Split into two ...
	(gdbscm_make_breakpoint, gdbscm_register_breakpoint_x): New functions.
	(bpscm_breakpoint_deleted): Reset breakpoint number and stop function.
	(scheme_function breakpoint_functions): Update.
	* guile/lib/gdb.scm: Delete create-breakpoint!.  Rename
	breakpoint-delete! to delete-breakpoint!.  Add make-breakpoint,
	register-breakpoint!.

	testsuite/
	* gdb.guile/scm-breakpoint.exp: Update.
	Add tests for breakpoint registration.

	doc/
	* guile.texi (Breakpoints In Guile): Update.
2014-06-04 19:44:30 -07:00
Joel Brobecker ef7cab6ba1 gdbserver crash if the_target->supports_z_point_type is NULL
When debugging on LynxOS targets (and probably on SPU targets as well),
inserting a breakpoint and resuming the program's execution causes
GDBserver to crash.

The crash occurs while handling the Z0 packet sent by GDB to insert
our breakpoint, because z_type_supported calls
the_target->supports_z_point_type without checking that it is not NULL
This patch fixes the issue by making z_type_supported return false if
the_target->supports_z_point_type is NULL.

gdb/gdbserver/ChangeLog:

        PR server/17023
        * mem-break.c (z_type_supported): Return zero if
        THE_TARGET->SUPPORTS_Z_POINT_TYPE is NULL.

Tested on ppx-lynx5.
2014-06-04 17:57:21 -04:00
Tom Tromey 012370f681 handle VLA in a struct or union
It is valid in GNU C to have a VLA in a struct or union type, but gdb
did not handle this.

This patch adds support for these cases in the obvious way.

Built and regtested on x86-64 Fedora 20.
New tests included.

2014-06-04  Tom Tromey  <tromey@redhat.com>

	* ada-lang.c (ada_template_to_fixed_record_type_1): Use
	value_from_contents_and_address_unresolved.
	(ada_template_to_fixed_record_type_1): Likewise.
	(ada_which_variant_applies): Likewise.
	* value.h (value_from_contents_and_address_unresolved): Declare.
	* value.c (value_from_contents_and_address_unresolved): New
	function.
	* gdbtypes.c (is_dynamic_type, resolve_dynamic_type)
	<TYPE_CODE_STRUCT, TYPE_CODE_UNION>: New cases.
	(resolve_dynamic_struct, resolve_dynamic_union): New functions.

2014-06-04  Tom Tromey  <tromey@redhat.com>

	* gdb.base/vla-datatypes.exp: Add tests for VLA-in-structure and
	VLA-in-union.
	* gdb.base/vla-datatypes.c (vla_factory): Add vla_struct,
	inner_vla_struct, vla_union types.  Initialize objects of those
	types and compute their sizes.
2014-06-04 14:28:22 -06:00
Tom Tromey 92e2a17f9b minor cleanups in is_dynamic_type
I noticed that gdbtypes.c:is_dynamic_type has some unneeded "break"s.
This patch cleans up the function a bit, removing those and removing
the switch's default case so that the end of the function is a bit
clearer.

2014-06-04  Tom Tromey  <tromey@redhat.com>

	* gdbtypes.c (is_dynamic_type): Remove unneeded "break"s.
2014-06-04 14:28:20 -06:00
Tom Tromey c0939df1ce constify to_attach
This constifies the "args" argument to the target_ops to_attach
method.

I updated all instances of the method.  I could not compile all of
them but I hand-inspected them.  In all cases either the argument is
ignored, or it is passed to parse_pid_to_attach.  (linux-nat does some
extra stuff, but that one I built...)

If you want to try it on your host of choice, please do so.

The code in parse_pid_to_attach seems a little bogus to me.  If there
is a platform with a broken strtoul, we have better methods for fixing
the issue now.  However, I left the code as is since it is clearly ok
to do so.

Built and regtested on x86-64 Fedora 20.

2014-06-04  Tom Tromey  <tromey@redhat.com>

	* procfs.c (procfs_attach): Make "args" const.
	* windows-nat.c (windows_attach): Make "args" const.
	* nto-procfs.c (procfs_attach): Make "args" const.
	* inf-ttrace.c (inf_ttrace_attach): Make "args" const.
	* go32-nat.c (go32_attach): Make "args" const.
	* gnu-nat.c (gnu_attach): Make "args" const.
	* darwin-nat.c (darwin_attach): Make "args" const.
	* inf-ptrace.c (inf_ptrace_attach): Make "args" const.
	* linux-nat.c (linux_nat_attach): Make "args" const.
	* remote.c (extended_remote_attach_1, extended_remote_attach):
	Make "args" const.
	* target.h (struct target_ops) <to_attach>: Make "args" const.
	(find_default_attach): Likewise.
	* utils.c (parse_pid_to_attach): Make "args" const.
	* utils.h (parse_pid_to_attach): Update.
2014-06-04 11:11:43 -06:00
Tom Tromey 8eaff7cd13 convert to_thread_address_space to use TARGET_DEFAULT_FUNC
This converts to_thread_address_space to use TARGET_DEFAULT_FUNC.

This method was one of a handful not using the normal target
delegation approach.  The only rationale here is consistency in the
target vector.

Built and regtested on x86-64 Fedora 20.

2014-06-04  Tom Tromey  <tromey@redhat.com>

	* target-delegates.c: Rebuild.
	* target.c (default_thread_address_space): New function.
	(target_thread_address_space): Simplify.
	* target.h (struct target_ops) <to_thread_address_space>: Add
	TARGET_DEFAULT_FUNC.
2014-06-04 09:24:27 -06:00
Yao Qi 03388bb71c Tweak sss-bp-on-user-bp.exp
sss-bp-on-user-bp.c has an assumption that write to integer can be
compiled to a single instruction, which isn't true on some arch, such
as arm.  This test requires setting two breakpoints on two consecutive
instructions, so this patch is to get the address of the next
instruction via disassemble and set the 2nd breakpoint there.  This
approach is portable.

This patch fixes the fails in sss-bp-on-user-bp.exp on arm-none-abi
target.  There is no change in x86 test results.  I also revert the
patch to PR breakpoints/17000, and verified that the patched
sss-bp-on-user-bp.exp still trigger the fail on
x86-with-software-single-step.

gdb/testsuite:

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

	* gdb.base/sss-bp-on-user-bp.c (main): Remove comments.
	* gdb.base/sss-bp-on-user-bp.exp: Don't set breakpoint on
	"set bar break here".  Get the next instruction address and
	set breakpoint there.  Remove "bar break" from the regexp
	patterns.
2014-06-04 20:53:47 +08:00
Doug Evans 1913f160bd * guile/scm-type.c (type_smob): Remove duplicate typedef. 2014-06-04 00:26:03 -07:00
Markus Metzger 70ad5bfff3 btrace: async support
Add support for async command execution.  This fixes the gdb.btrace tests.

	* record-btrace.c: Include event-loop.h and inf-loop.h.
	(record_btrace_resume_exec_dir)
	(record_btrace_async_inferior_event_handler)
	(record_btrace_handle_async_inferior_event): New.
	(record_btrace_open): Create async event handler.
	(record_btrace_close): Delete async event handler.
	(record_btrace_resume): Set record_btrace_resume_exec_dir,
	Mark async event handler.
	(record_btrace_execution_direction): New.
	(init_record_btrace_ops): Initialize to_execution_direction.
2014-06-04 09:09:21 +02:00
Hui Zhu 9f5a4cef68 Add system test before "set remote system-call-allowed 1" to fileio.exp
This patch is update version according to the discussion in
https://www.sourceware.org/ml/gdb-patches/2009-11/msg00090.html.
If test get the target doesn't support fileio system according to the
remote log.   It will set this test as "unsupported".

Before I made this patch, I want add a check before all of tests in this
file.  But I found that the target maybe support one call but not others.
For example: my target support Fwrite, Fopen and so on.  But not Fgettimeofday.
And it doesn't support Fsystem NULL but it support Fsystem not NULL.
So I think if we want to check target support fileio, we need check them
one by one.

2014-06-04  Nathan Sidwell  <nathan@codesourcery.com>
	    Hui Zhu  <hui@codesourcery.com>

	* gdb.base/fileio.exp: Add test for shell not available as well as
	available.
	* gdb.base/fileio.c (test_system): Check for shell twice.
2014-06-04 14:38:16 +08:00
Yao Qi 90a45c4d5f Fix a regexp pattern in gdb.base/auto-connect-native-target.exp
When I test gdb head (for 7.8 release) on arm-none-eabi, I find the
following this failure, which are caused by the improper regexp
pattern in the test.

(gdb) help target native^M
Undefined target command: "native".  Try "help target".^M
(gdb) FAIL: gdb.base/auto-connect-native-target.exp: help target native

The space in front of "$gdb_prompt $" looks redundant, and this patch
is to remove it from the regexp pattern.

gdb/testsuite:

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

	* gdb.base/auto-connect-native-target.exp: Remove redundant
	space from the regexp pattern.
2014-06-04 13:30:44 +08:00
Yao Qi 70017e417c Fix regexp pattern in gdb.base/default.exp
I see this failure on arm-none-eabi gdb testing.

target native^M
Undefined target command: "native".  Try "help target".^M
(gdb) FAIL: gdb.base/default.exp: target native

This patch is to update the regexp pattern to match "native" instead of
"child".

gdb/testsuite:

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

	* gdb.base/default.exp: Replace "child" with "native" in
	regexp pattern.
2014-06-04 13:30:39 +08:00
Doug Evans b6210538cf * guile/scm-param.c (pascm_make_param_smob): Add ARI comment.
(gdbscm_make_parameter): Ditto.
2014-06-03 20:37:56 -07:00
Doug Evans a5b1fd2780 resize_section_table cleanup
* exec.c (exec_close_1): Call clear_section_table instead of
	resize_section_table.
	(clear_section_table): New function.
	(resize_section_table): Make static.  Rename arg num_added to
	adjustment.
	* exec.h (clear_section_table): Declare.
	(resize_section_table): Delete.
	* progspace.c (release_program_space): Call clear_section_table
	instead of resize_section_table.
2014-06-03 13:48:12 -07:00
Joel Brobecker 1e47491b33 gdb/doc/python.texi: Fix reference to "Progspaces In Python".
A recent change broke the documentation build due to a think-o
in a reference.  Fixed thusly.

gdb/doc/ChangeLog:

        * python.texi (Xmethod API): Fix reference to "Progspaces In
        Python".

Tested by rebuilding all documentation formats.
2014-06-03 10:41:17 -07:00
Siva Chandra 0c6e92a52c Documentation of the xmethod support in GDB Python API.
* NEWS (Python Scripting): Add entry about the new xmethods
	feature.

	doc/
	*  python.texi (Xmethods In Python, XMethod API)
	(Writing an Xmethod): New nodes.
	(Python API): New menu entries "Xmethods In Python",
	"Xmethod API", "Writing an Xmethod".
2014-06-03 10:07:45 -07:00
Siva Chandra 883964a75e Xmethod support in Python.
* python/py-xmethods.c: New file.
	* python/py-objfile.c (objfile_object): New field 'xmethods'.
	(objfpy_dealloc): XDECREF on the new xmethods field.
	(objfpy_new, objfile_to_objfile_object): Initialize xmethods
	field.
	(objfpy_get_xmethods): New function.
	(objfile_getset): New entry 'xmethods'.
	* python/py-progspace.c (pspace_object): New field 'xmethods'.
	(pspy_dealloc): XDECREF on the new xmethods field.
	(pspy_new, pspace_to_pspace_object): Initialize	xmethods
	field.
	(pspy_get_xmethods): New function.
	(pspace_getset): New entry 'xmethods'.
	* python/python-internal.h: Add declarations for new functions.
	* python/python.c (_initialize_python): Invoke
	gdbpy_initialize_xmethods.
	* python/lib/gdb/__init__.py (xmethods): New
	attribute.
	* python/lib/gdb/xmethod.py: New file.
	* python/lib/gdb/command/xmethods.py: New file.

	testuite/
	* gdb.python/py-xmethods.cc: New testcase to test xmethods.
	* gdb.python/py-xmethods.exp: New tests to test xmethods.
	* gdb.python/py-xmethods.py: Python script supporting the
	new testcase and tests.
2014-06-03 10:03:07 -07:00
Siva Chandra 58992dc550 Missed ChangeLog entry in the previous commit. 2014-06-03 09:56:58 -07:00
Siva Chandra 233e8b28cf Lookup and invoke debug methods of C++ classes if they are the best match.
* eval.c (evaluate_subexp_standard): Call the xmethod if the
	best match method returned by find_overload_match is an xmethod.
	* valarith.c (value_x_binop, value_x_unop): Call the xmethod if
	the best matching operator returned by find_overload_match is an
	xmethod.
	* valops.c: #include "extension.h".
	(find_method_list): Add "fn_list" and "xm_worker_vec" arguments.
	Return void.  The list of matching source methods is returned in
	"fn_list" and a vector of matching debug method workers is
	returned in "xm_worker_vec".  Update all callers.
	(value_find_oload_method_list): Likewise.
	(find_oload_champ): Add "xm_worker_vec" parameter.  If it is
	non-NULL, then the index of the best matching method in this
	vector is returned.  Update all callers.
	(find_overload_match): Include xmethods while performing overload
	resolution.
2014-06-03 09:54:21 -07:00
Siva Chandra e81e7f5e38 Add xmethod interface to the extension language API.
* defs.h (enum lval_type): New enumerator "lval_xcallable".
	* extension-priv.h (struct extension_language_ops): Add the
	xmethod interface.
	* extension.c (new_xmethod_worker, clone_xmethod_worker,
	get_matching_xmethod_workers, get_xmethod_argtypes,
	invoke_xmethod, free_xmethod_worker,
	free_xmethod_worker_vec): New functions.
	* extension.h: #include "common/vec.h".
	New function declarations.
	(struct xmethod_worker): New struct.
	(VEC (xmethod_worker_ptr)): New vector type.
	(xmethod_worker_ptr): New typedef.
	(xmethod_worker_vec): Likewise.
	* gdbtypes.c (gdbtypes_post_init): Initialize "xmethod" field of
	builtin_type.
	* gdbtypes.h (enum type_code): New enumerator TYPE_CODE_XMETHOD.
	(struct builtin_type): New field "xmethod".
	* valarith.c (value_ptradd): Assert that the value argument is not
	lval_xcallable.
	* valops.c (value_must_coerce_to_target): Return 0 for
	lval_xcallable values.
	* value.c (struct value): New field XM_WORKER in the field
	LOCATION.
	(value_address, value_raw_address): Return 0 for lval_xcallable
	values.
	(set_value_address): Assert that the value is not an
	lval_xcallable.
	(value_free): Free the associated xmethod worker when freeing
	lval_xcallable values.
	(set_value_component_location): Assert that the WHOLE value is not
	lval_xcallable.
	(value_of_xmethod, call_xmethod): New functions.
	* value.h: Declare "struct xmethod_worker".
	Declare new functions value_of_xmethod, call_xmethod.
2014-06-03 09:49:26 -07:00
Joel Brobecker ef370185fc User breakpoint ignored if software-single-step at same location
with the following code...

    12    Nested;   -- break #1
    13    return I; -- break #2
    14  end;

(line 12 is a call to function Nested)

... we have noticed the following errorneous behavior on ppc-aix,
where, after having inserted a breakpoint at line 12 and line 13,
and continuing from the breakpoint at line 12, the program never
stops at line 13, running away until the program terminates:

    % gdb -q func
    (gdb) b func.adb:12
    Breakpoint 1 at 0x10000a24: file func.adb, line 12.
    (gdb) b func.adb:13
    Breakpoint 2 at 0x10000a28: file func.adb, line 13.
    (gdb) run
    Starting program: /[...]/func

    Breakpoint 1, func () at func.adb:12
    12        Nested;   -- break #1
    (gdb) c
    Continuing.
    [Inferior 1 (process 4128872) exited with code 02]

When resuming from the first breakpoint, GDB first tries to step out
of that first breakpoint.  We rely on software single-stepping on this
platform, and it just so happens that the address of the first
software single-step breakpoint is the same as the user's breakpoint
#2 (0x10000a28).  So, with infrun and target traces turned on (but
uninteresting traces snip'ed off), the "continue" operation looks like
this:

    (gdb) c
    ### First, we insert the user breakpoints (the second one is an internal
    ### breakpoint on __pthread_init). The first user breakpoint is not
    ### inserted as we need to step out of it first.
    target_insert_breakpoint (0x0000000010000a28, xxx) = 0
    target_insert_breakpoint (0x00000000d03f3800, xxx) = 0
    ### Then we proceed with the step-out-of-breakpoint...
    infrun: resume (step=1, signal=GDB_SIGNAL_0), trap_expected=1, current thread [process 15335610] at 0x10000a24
    ### That's when we insert the SSS breakpoints...
    target_insert_breakpoint (0x0000000010000a28, xxx) = 0
    target_insert_breakpoint (0x00000000100009ac, xxx) = 0
    ### ... then let the inferior resume...
    target_resume (15335610, continue, 0)
    infrun: wait_for_inferior ()
    target_wait (-1, status, options={}) = 15335610,   status->kind = stopped, signal = GDB_SIGNAL_TRAP
    infrun: target_wait (-1, status) =
    infrun:   15335610 [process 15335610],
    infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
    infrun: infwait_normal_state
    infrun: TARGET_WAITKIND_STOPPED
    infrun: stop_pc = 0x100009ac
    ### At this point, we stopped at the second SSS breakpoint...
    target_stopped_by_watchpoint () = 0
    ### We remove the SSS breakpoints...
    target_remove_breakpoint (0x0000000010000a28, xxx) = 0
    target_remove_breakpoint (0x00000000100009ac, xxx) = 0
    target_stopped_by_watchpoint () = 0
    ### We find that we're not done, so we resume....
    infrun: no stepping, continue
    ### And thus insert the user breakpoints again, except we're not
    ### inserting the second breakpoint?!?
    target_insert_breakpoint (0x0000000010000a24, xxx) = 0
    infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 15335610] at 0x100009ac
    target_resume (-1, continue, 0)
    infrun: prepare_to_wait
    target_wait (-1, status, options={}) = 15335610,   status->kind = exited, status = 2

What happens is that the removal of the software single-step
breakpoints effectively removed the breakpoint instruction from
inferior memory.  But because such breakpoints are inserted directly
as raw breakpoints rather than through the normal chain of
breakpoints, we fail to notice that one of the user breakpoints points
to the same address and that this user breakpoint is therefore
effectively un-inserted.  When resuming after the single-step, GDB
thinks that the user breakpoint is still inserted and therefore does
not need to insert it again.

This patch teaches the insert and remove routines of both regular and
raw breakpoints to be aware of each other.  Special care needs to be
applied in case the target supports evaluation of breakpoint
conditions or commands.

gdb/ChangeLog:

	PR breakpoints/17000
	* breakpoint.c (find_non_raw_software_breakpoint_inserted_here):
	New function, extracted from software_breakpoint_inserted_here_p.
	(software_breakpoint_inserted_here_p): Replace factored out code
	by call to find_non_raw_software_breakpoint_inserted_here.
	(bp_target_info_copy_insertion_state): New function.
	(bkpt_insert_location): Handle the case of a single-step
	breakpoint already inserted at the same address.
	(bkpt_remove_location): Handle the case of a single-step
	breakpoint still inserted at the same address.
	(deprecated_insert_raw_breakpoint): Handle the case of non-raw
	breakpoint already inserted at the same address.
	(deprecated_remove_raw_breakpoint): Handle the case of a
	non-raw breakpoint still inserted at the same address.
	(find_single_step_breakpoint): New function, extracted from
	single_step_breakpoint_inserted_here_p.
	(find_single_step_breakpoint): New function,
	factored out from single_step_breakpoint_inserted_here_p.
	(single_step_breakpoint_inserted_here_p): Reimplement.

gdb/testsuite/ChangeLog:

	PR breakpoints/17000
	* gdb.base/sss-bp-on-user-bp.exp: Remove kfail.
	* gdb.base/sss-bp-on-user-bp-2.exp: Remove kfail.

Tested on ppc-aix with AdaCore's testsuite.  Tested on x86_64-linux,
(native and gdbserver) with the official testsuite.  Also tested on
x86_64-linux through Pedro's branch enabling software single-stepping
on that platform (native and gdbserver).
2014-06-03 17:42:19 +01:00
Brad Mouring 1e2ccb612d gdb/source.c: Fix matching path substitute rule listing
The check for the source (or "from") directory snippet in listing
matching path substitution rules currently will not match anything
other than a direct match of the "from" field in a substitution rule,
resulting in the incorrect behavior below:

...
(gdb) set substitute-path /a/path /another/path
(gdb) show substitute-path
List of all source path substitution rules:
  `/a/path' -> `/another/path'.
(gdb) show substitute-path /a/path/to/a/file.ext
Source path substitution rule matching `/a/path/to/a/file.ext':
(gdb) show substitute-path /a/path
Source path substitution rule matching `/a/path':
  `/a/path' -> `/another/path'.
...

This change effects the following behavior by (sanely) checking
with the length of the "from" portion of a rule and ensuring that
the next character of the path considered for substitution is a path
delimiter (or NULL). With this change, the following behavior is
garnered:
...
(gdb) set substitute-path /a/path /another/path
(gdb) show substitute-path
List of all source path substitution rules:
  `/a/path' -> `/another/path'.
(gdb) show substitute-path /a/path/to/a/file.ext
Source path substitution rule matching `/a/path/to/a/file.ext':
  `/a/path' -> `/another/path'.
(gdb) show substitute-path /a/pathological/case/that/should/fail.err
Source path substitution rule matching `/a/pathological/case/that/should/fail.err':
(gdb)

Also included is a couple of tests added to subst.exp to verify
this behavior in the test suite.

gdb/ChangeLog:

        * source.c (show_substitute_path_command): Fix display of matching
        substitution rules.

gdb/testsuite/ChangeLog:

        * gdb.ada/subst.exp: Add tests to verify partial path matching
        output.

This was tested on x86_64 Linux.
2014-06-03 07:17:06 -07:00
Pedro Alves c6ec5ab23a Skip sss-bp-on-user-bp-2.exp on remote hardware step targets.
gdb/testsuite/
2014-06-03  Pedro Alves  <palves@redhat.com>

	* gdb.base/sss-bp-on-user-bp-2.exp: Skip if testing with a remote
	target that doesn't use software single-stepping.
2014-06-03 14:04:48 +01:00
Gary Benson d3448d8523 This patch replaces a call to cplus_demangle with a call to
gdb_demangle.  This change was included in an RFC from last
March [1] but omitted from the eventual commit.

[1] https://sourceware.org/ml/gdb-patches/2013-03/msg00235.html

2014-06-03  Gary Benson  <gbenson@redhat.com>

	* gnu-v2-abi.c (gnuv2_value_rtti_type): Use gdb_demangle.
2014-06-03 13:49:20 +01:00
Pedro Alves 835c559fd5 PR breakpoints/17000: user breakpoint not inserted if software-single-step at same location - test
GDB gets confused when removing a software single-step breakpoint that
is at the same address as another breakpoint.  Add another kfailed
test.

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

	PR breakpoints/17000
	* gdb.base/sss-bp-on-user-bp-2.c: New file.
	* gdb.base/sss-bp-on-user-bp-2.exp: New file.
2014-06-03 12:46:46 +01:00
Doug Evans 06eb158633 Add parameter support for Guile.
* Makefile.in (SUBDIR_GUILE_OBS): Add scm-param.o.
	(SUBDIR_GUILE_SRCS): Add scm-param.c.
	(scm-param.o): New rule.
	* guile/guile-internal.h (gdbscm_gc_dup_argv): Declare.
	(gdbscm_misc_error): Declare.
	(gdbscm_canonicalize_command_name): Declare.
	(gdbscm_scm_to_host_string): Declare.
	(gdbscm_scm_from_host_string): Declare.
	(gdbscm_initialize_parameters): Declare.
	* guile/guile.c (initialize_gdb_module): Call
	gdbscm_initialize_parameters.
	* guile/lib/gdb.scm: Export parameter symbols.
	* guile/scm-cmd.c (gdbscm_canonicalize_command_name): Renamed from
	cmdscm_canonicalize_name and made public.  All callers updated.
	* guile/scm-exception.c (gdbscm_misc_error): New function.
	* guile/scm-param.c: New file.
	* guile/scm-string.c (gdbscm_scm_to_string): Add comments.
	(gdbscm_scm_to_host_string): New function.
	(gdbscm_scm_from_host_string): New function.
	* scm-utils.c (gdbscm_gc_dup_argv): New function.

	testsuite/
	* gdb.guile/scm-parameter.exp: New file.

	doc/
	* guile.texi (Guile API): Add entry for Parameters In Guile.
	(GDB Scheme Data Types): Mention <gdb:parameter> object.
	(Parameters In Guile): New node.
2014-06-03 01:58:15 -07:00
Doug Evans e698b8c41c Add command support for Guile.
* Makefile.in (SUBDIR_GUILE_OBS): Add scm-cmd.o.
	(SUBDIR_GUILE_SRCS): Add scm-cmd.c.
	(scm-cmd.o): New rule.
	* guile/guile-internal.h (gdbscm_gc_xstrdup): Declare.
	(gdbscm_user_error_p): Declare.
	(gdbscm_parse_command_name): Declare.
	(gdbscm_valid_command_class_p): Declare.
	(gdbscm_initialize_commands): Declare.
	* guile/guile.c (initialize_gdb_module): Call
	gdbscm_initialize_commands.
	* guile/lib/gdb.scm: Export command symbols.
	* guile/lib/gdb/init.scm (%exception-keys): Add gdb:user-error.
	(throw-user-error): New function.
	* guile/scm-cmd.c: New file.
	* guile/scm-exception.c (user_error_symbol): New static global.
	(gdbscm_user_error_p): New function.
	(gdbscm_initialize_exceptions): Set user_error_symbol.
	* scm-utils.c (gdbscm_gc_xstrdup): New function.

	testsuite/
	* gdb.guile/scm-cmd.c: New file.
	* gdb.guile/scm-cmd.exp: New file.

	doc/
	* guile.texi (Guile API): Add entry for Commands In Guile.
	(Basic Guile) <parse-and-eval>: Add reference.
	(Basic Guile) <string->argv>: Move definition to Commands In Guile.
	(GDB Scheme Data Types): Mention <gdb:command> object.
	(Commands In Guile): New node.
2014-06-03 00:29:49 -07:00
Phil Muldoon fb1f94b09a Don't remove #-comments.
When using the multi-line feature, we don't want the gdb CLI to remove
comments from the command list, as this will remove things like
"#define".

	* top.c (command_loop): Handle comments here...
	(command_line_input): ... not here.
2014-06-03 00:01:39 -07:00
Doug Evans ded0378278 Add progspace support for Guile.
* Makefile.in (SUBDIR_GUILE_OBS): Add scm-progspace.o.
	(SUBDIR_GUILE_SRCS): Add scm-progspace.c.
	(scm-progspace.o): New rule.
	* guile/guile-internal.h (pspace_smob): New typedef.
	(psscm_pspace_smob_pretty_printers): Declare.
	(psscm_pspace_smob_from_pspace): Declare.
	(psscm_scm_from_pspace): Declare.
	* guile/guile.c (initialize_gdb_module): Call
	gdbscm_initialize_pspaces.
	* guile/lib/gdb.scm: Export progspace symbols.
	* guile/lib/gdb/printing.scm (prepend-pretty-printer!): Add progspace
	support.
	(append-pretty-printer!): Ditto.
	* guile/scm-pretty-print.c (ppscm_find_pretty_printer_from_progspace):
	Implement.
	* guile/scm-progspace.c: New file.

	doc/
	* guile.texi (Guile API): Add entry for Progspaces In Guile.
	(GDB Scheme Data Types): Mention <gdb:progspace> object.
	(Progspaces In Guile): New node.

	testsuite/
	* gdb.guile/scm-pretty-print.exp: Add tests for objfile and progspace
	pretty-printer lookup.
	* gdb.guile/scm-pretty-print.scm (pp_s-printer): New function.
	(make-pp_s-printer): Call it.
	(make-pretty-printer-from-dict): New function.
	(lookup-pretty-printer-maker-from-dict): New function.
	(*pretty-printer*): Simplify.
	(make-objfile-pp_s-printer): New function.
	(install-objfile-pretty-printers!): New function.
	(make-progspace-pp_s-printer): New function.
	(install-progspace-pretty-printers!): New function.
	* gdb.guile/scm-progspace.c: New file.
	* gdb.guile/scm-progspace.exp: New file.
2014-06-02 23:46:27 -07:00
Alan Modra 397998fc32 Support fusion for ELFv2 stubs
Power8 fuses addis,addi and addis,ld sequences when the target of the
addis is the same as the addi/ld.  Thus
    addis r12,r2,xxx@ha
    addi r12,r12,xxx@l / ld r12,xxx@l(r12)
is faster than
    addis r11,r2,xxx@ha
    addi r12,r11,xxx@l / ld r12,xxx@l(r11)
So use the form that allows fusion in plt call and branch stubs.

bfd/
	* elf64-ppc.c (ADDIS_R12_R2): Define.
	(build_plt_stub): Support fusion on ELFv2 stub.
	(ppc_build_one_stub): Likewise for plt branch stubs.
gold/
	* powerpc.cc (addis_12_2): Define.
	(Stub_table::do_write): Support fusion on ELFv2 stubs.
ld/testsuite/
	* ld-powerpc/elfv2exe.d: Update for changed plt call stubs.
gdb/
	* ppc64-tdep.c (ppc64_standard_linkage8): New.
	(ppc64_skip_trampoline_code): Recognise ELFv2 stub supporting fusion.
2014-06-03 10:55:29 +09:30
Doug Evans 6aa5f3a6ed Add support for skeletonless type units.
* dwarf2read.c (struct dwarf2_per_objfile): New member
	n_allocated_type_units.
	(struct dwarf2_per_objfile) <tu_stats>: New member
	nr_all_type_units_reallocs.
	(create_signatured_type_table_from_index): Initialize
	n_allocated_type_units
	(create_all_type_units): Ditto.
	(add_type_unit): Move up in file.  New arg slot.
	All callers updated.  Increase space for all_type_units more
	efficiently.
	(fill_in_sig_entry_from_dwo_entry): Handle psymtabs.
	(lookup_dwo_signatured_type): Handle skeletonless TUs.
	(lookup_dwp_signatured_type): Ditto.
	(init_tu_and_read_dwo_dies): New arg use_existing_cu.
	All callers updated.
	(build_type_psymtabs_1): Leave type_unit_groups as
	NULL if no TUs present.
	(print_tu_stats): New function.
	(process_skeletonless_type_unit): New function.
	(process_dwo_file_for_skeletonless_type_units): New
	function.
	(process_skeletonless_type_units): New function.
	(dwarf2_build_psymtabs_hard): Handle skeletonless TUs.
	Call print tu_stats if debugging enabled.
2014-06-02 17:16:07 -07:00
Pedro Alves 41fac0cf49 Installing a breakpoint on top of a dprintf makes GDB lose control.
While the full fix for PR 15180 isn't in, it's best if we at least
make sure that GDB doesn't lose control when a breakpoint is set at
the same address as a dprintf.

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

	* breakpoint.c (build_target_command_list): Don't build a command
	list if we have any duplicate location that isn't a dprintf.

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

	* gdb.base/dprintf-bp-same-addr.c: New file.
	* gdb.base/dprintf-bp-same-addr.exp: New file.
2014-06-02 23:29:13 +01:00
Pedro Alves cd1608cc4e dprintf-style agent can't explain a trap.
If some event happens to trigger at the same address as a dprintf-style
agent dprintf is installed, GDB will complain, like:

 (gdb) continue
 Continuing.
 May only run agent-printf on the target
 (gdb)

Such dprintfs are completely handled on the target side, so they can't
explain a stop, but GDB is currently putting then on the bpstat chain
anyway, because they currently unconditionally use bkpt_breakpoint_hit
as breakpoint_hit method.

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

	* breakpoint.c (dprintf_breakpoint_hit): New function.
	(initialize_breakpoint_ops): Install it as dprintf's
	breakpoint_hit method.
2014-06-02 23:28:54 +01:00
Pedro Alves 0a261ed82e gdbserver: on GDB breakpoint reinsertion, also delete the breakpoint's commands.
If GDB decides to change the breakpoint's conditions or commands,
it'll reinsert the same breakpoint again, with the new options
attached, without deleting the previous breakpoint.  E.g.,

 (gdb) set breakpoint always-inserted on
 (gdb) b main if 0
 Breakpoint 1 at 0x400594: file foo.c, line 21.
 Sending packet: $Z0,400594,1;X3,220027#68...Packet received: OK
 (gdb) b main
 Breakpoint 15 at 0x400594: file foo.c, line 21.
 Sending packet: $Z0,400594,1#49...Packet received: OK

GDBserver understands this and deletes the breakpoint's previous
conditions.  But, it forgets to delete the previous commands.

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

	* ax.c (gdb_free_agent_expr): New function.
	* ax.h (gdb_free_agent_expr): New declaration.
	* mem-break.c (delete_gdb_breakpoint_1): Also clear the commands
	list.
	(clear_breakpoint_conditions, clear_breakpoint_commands): Make
	static.
	(clear_breakpoint_conditions_and_commands): New function.
	* mem-break.h (clear_breakpoint_conditions): Delete declaration.
	(clear_breakpoint_conditions_and_commands): New declaration.
2014-06-02 22:27:32 +01:00