Make internal_vproblem always work

internal_vproblem can be called (via malloc_failure) from almost the
first line of captured_main, but it will crash if called before the
first call to set_width.  This commit makes internal_vproblem work
at any time.

There are two parts to this.  If called before gdb_stderr is set up,
internal_vproblem will fall back to printing the message on regular
stderr and aborting.  If called after gdb_stderr is set up but before
filtered printing is set up, internal_vproblem will operate as usual
except that it can not query whether to quit and/or dump core so it
defaults to doing both.

gdb/ChangeLog:

	* utils.h (filtered_printing_initialized): New declaration.
	* utils.c (abort_with_message): New function.
	(internal_vproblem): Use abort_with_message for first level
	recursive internal problems, and if gdb_stderr is not set up.
	Protect calls to target_terminal_ours, begin_line and query.
Make error usable earlier

error (and other exception-throwing functions) are callable from the
first line of captured_main, but the exception printing code will
crash if called before the first call to set_width.  This commit makes
the exception printing code usable from the moment gdb_stderr is set
up.

gdb/ChangeLog:

	* exceptions.c (print_flush): Protect calls to
	target_terminal_ours and wrap_here.
Make warning usable earlier

warning will crash if called before the first call to set_width.  This
commit makes the warning usable from the moment gdb_stderr is set up.

gdb/ChangeLog:

	* utils.c (vwarning): Protect calls to target_terminal_ours
	and wrap_here.
Replace hardwired error handlers in tui_initialize_io

tui_initialize_io contains a pair of hardwired fprintf/exit error
handlers.  I was unable to find any documentation as to why they're
hardwired (the code appeared in a monolithic block back in 2001:
https://sourceware.org/ml/gdb-patches/2001-07/msg00490.html) and I
was also unable to come up with a situation where error would not
be suitable, so I have replaced both handlers with calls to error.

gdb/ChangeLog:

	* tui/tui-io.c (tui_initialize_io): Replace two fprintf/exit
	pairs with calls to error.  Wrap the message with _().
Replace hardwired error handler in captured_main

If the requested interpreter cannot be set captured_main reports the
error with a hardwired fprintf/exit pair.  A fprintf/exit pair on the
previous line was replaced with a call to error in March 2003
(https://sourceware.org/ml/gdb-patches/2003-03/msg00444.html) but I
found no documentation as to why this particular hardwired handler
was left untouched.  I was also unable to come up with a situation
where error would not be suitable, so I have replaced it with a call
to error.

gdb/ChangeLog:

	* main.c (captured_main): Replace a fprintf/exit
	pair with a call to error.  Wrap the message with _().
Replace hardwired error handler in go32_create_inferior

go32_create_inferior invokes a hardwired fprintf/exit error handler
if v2loadimage fails.  I could find no reason for this other than that
the block seems to have been copy-and-pasted from v2loadimage's
manpage.  This commit replaces the hardwired handler with a call to
error.

gdb/ChangeLog:

	* go32-nat.c (go32_create_inferior): Replace a fprintf/
	exit pair with a call to error.  Wrap the message with _().
Replace all usage errors with calls to error

This commit replaces the hardwired fprintf/exit error handlers
for usage errors with calls to error.

gdb/ChangeLog:

	* main.c (captured_main): Handle usage errors with error.
Unify startup and option-parsing warnings

Various warnings are emitted during startup and option-parsing using
fprintf_unfiltered.  One warning is prefixed with the command name,
the others are not.  This commit replaces these hardwired warnings
with calls to warning.  It also sets warning_pre_print to prefix all
warnings with the command name until option parsing is complete.

gdb/ChangeLog:

	* main.c (captured_main): Use warning during startup.
	Prefix startup warning messages with command name.
Move internal_{,v}warning to common/errors.[ch]

This commit moves internal_warning and internal_vwarning into
common/errors.[ch].

gdb/ChangeLog:

	* common/errors.h (internal_warning): New declaration.
	(internal_vwarning): Likewise.
	* common/errors.c (internal_warning): New function.
	* utils.h (internal_warning): Don't declare.
	(internal_vwarning): Likewise.
	* utils.c (internal_warning): Removed.

gdb/gdbserver/ChangeLog:

	* utils.c (internal_vwarning): New function.
Move cleanups.[ch] to common

This commit moves cleanups.[ch] into gdb/common/.  The only change to
the content of the files is that cleanups.c's include list was altered
to match its new location.

gdb/ChangeLog:

	* cleanups.h: Moved to...
	* common/cleanups.h: New file.
	* cleanups.c: Moved to...
	* common/cleanups.c: New file.  Include common-defs.h and
	cleanups.h.  Do not include defs.h.
	* Makefile.in (SFILES): Replace cleanups.c with common/cleanups.c.
	(HFILES_NO_SRCDIR): Replace cleanups.h with common/cleanups.h.
	(cleanups.o): New rule.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/cleanups.c.
	(OBS): cleanups.o.
	(cleanups.o): New rule.
Introduce common/gdb_setjmp.h

This commit creates a new file, common/gdb_setjmp.h, to hold some
portability macros for setjmp/longjmp et al. that are used by the
exceptions subsystem and by the demangler crash catcher.

gdb/ChangeLog:

	* common/gdb_setjmp.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/gdb_setjmp.h.
	* configure.ac: Move sigsetjmp check...
	* common/common.m4: ...here.
	* configure: Regenerate.
	* cp-support.c (SIGJMP_BUF): Delete.
	(SIGSETJMP): Likewise.
	(SIGLONGJMP): Likewise.
	* exceptions.h (gdb_setjmp.h): Include.
	(setjmp.h): Do not include.
	(EXCEPTIONS_SIGJMP_BUF): Delete.
	(EXCEPTIONS_SIGSETJMP): Likewise.
	(EXCEPTIONS_SIGLONGJMP): Likewise.
	Replace all uses of EXCEPTIONS_SIG* macros with SIG* macros
	from gdb_setjmp.h.
	* exceptions.c: Likewise.

gdb/gdbserver/ChangeLog:

	* config.in: Regenerate.
	* configure: Likewise.
Introduce common/common-exceptions.[ch]

This commit moves the exception throwing and catching code
into gdb/common/.  All exception printing code remains in
gdb/exceptions.[ch].

gdb/ChangeLog:

	* common/common-exceptions.h: New file.
	* common/common-exceptions.c: Likewise.
	* Makefile.in (SFILES): Add common/common-exceptions.c.
	(HFILES_NO_SRCDIR): Add common/common-exceptions.h.
	(COMMON_OBS): Add common-exceptions.o.
	(common-exceptions.o): New rule.
	* exceptions.h (common-exceptions.h): Include.
	(gdb_setjmp.h): Do not include.
	(return_reason): Moved to common-exceptions.h.
	(enum return_reason): Likewise.
	(RETURN_MASK): Likewise.
	(typedef return_mask): Likewise.
	(enum errors): Likewise.
	(struct gdb_exception): Likewise.
	(exceptions_state_mc_init): Likewise.
	(exceptions_state_mc_action_iter): Likewise.
	(exceptions_state_mc_action_iter_1): Likewise.
	(TRY_CATCH): Likewise.
	(throw_exception): Likewise.
	(throw_verror): Likewise.
	(throw_vquit): Likewise.
	(throw_error): Likewise.
	(throw_quit): Likewise.
	* exceptions.c (enum catcher_state): Moved to common-exceptions.c.
	(enum catcher_action): Likewise.
	(struct catcher): Likewise.
	(current_catcher): Likewise.
	(catcher_list_size): Likewise.
	(exceptions_state_mc_init): Likewise.
	(catcher_pop): Likewise.
	(exceptions_state_mc): Likewise.
	(exceptions_state_mc_action_iter): Likewise.
	(exceptions_state_mc_action_iter_1): Likewise.
	(throw_exception): Likewise.
	(exception_messages): Likewise.
	(exception_messages_size): Likewise.
	(throw_it): Likewise.
	(throw_verror): Likewise.
	(throw_vquit): Likewise.
	(throw_error): Likewise.
	(throw_quit): Likewise.
	(prepare_to_throw_exception): New function.

gdb/gdbserver/ChangeLog:

	* Makefile.in (SFILES): Add common/common-exceptions.c.
	(OBS): Add common-exceptions.o.
	(common-exceptions.o): New rule.
	* utils.c (prepare_to_throw_exception): New function.
Use exceptions and cleanups in gdbserver

This commit replaces the hacky "exception" system in gdbserver with
the exceptions and cleanups subsystem from GDB.

Only the catch/cleanup code in what was "main" has been updated to
use the new system.  Other parts of gdbserver can now be converted
to use TRY_CATCH and cleanups on an as-needed basis.

A side-effect of this commit is that some error messages will change
slightly, and in cases with multiple errors the error messages will
be printed in a different order.

gdb/gdbserver/ChangeLog:

	* server.h (setjmp.h): Do not include.
	(toplevel): Do not declare.
	(common-exceptions.h): Include.
	(cleanups.h): Likewise.
	* server.c (toplevel): Do not define.
	(exit_code): New static global.
	(detach_or_kill_for_exit_cleanup): New function.
	(main): New function.  Original main renamed to...
	(captured_main): New function.
	* utils.c (verror) [!IN_PROCESS_AGENT]: Use throw_verror.
[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>
[Patch, microblaze]: Communicate in larger blocks with the target

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
[Patch, microblaze]: Add slr and shr regs and little-endian breakpoint

Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
[Patch, microblaze]: Add mb singlestepping.

Fix prologue analysis for little-endian.
Always provide a frame base.

Signed-off-by: Edgar E. Iglesias <edgar@axis.com>
[Patch, microblaze]: Initial port of microblaze core reading support

Added support for reading notes in linux core dumps
Support for reading of PRSTATUS and PSINFO information for rebuilding
".reg" sections of core dumps at run time.

Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
[Patch, microblaze]: Add initial port of linux gdbserver

add gdb_proc_service_h to gdbserver microblaze-linux

gdbserver needs to initialise the microblaze registers

other archs use this step to run a *_arch_setup() to carry out all
architecture specific setup - may need to add in future

 * add linux-ptrace.o to gdbserver configure
 * gdb/configure.tgt: Set build_gdbserver=yes
 * Update breakpoint opcode
 * fix segfault on connecting gdbserver
 * add microblaze_linux_memory_remove_breakpoint
 * add set_solib_svr4_fetch_link_map_offsets
 * add set_gdbarch_fetch_tls_load_module_address
 * Force reading of r0 as 0, prevent stores

Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>