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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
[Patch, microblaze]: Add wdc.ext.clear and wdc.ext.flush insns

Added two new instructions, wdc.ext.clear and wdc.ext.flush,
to enable MicroBlaze to flush an external cache, which is
used with the new coherency support for multiprocessing.

Signed-off-by:nagaraju <nmekala@xilix.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
[Patch, microblaze]: Add mlittle-endian and mbig-endian flags

Added support in gas for mlittle-endian and mbig-endian flags
as options.

Updated show usage for MicroBlaze specific assembler options
to include new entries.

Signed-off-by:nagaraju <nmekala@xilix.com>
Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>