nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing

We observed on Windows 2012 that we were unable to unwind past
exception handlers. For instance, with any Ada program raising
an exception that does not get handled:

    % gnatmake -g a -bargs -shared
    % gdb a
    (gdb) start
    (gdb) catch exception unhandled
    Catchpoint 2: unhandled Ada exceptions
    (gdb) c
    Catchpoint 2, unhandled CONSTRAINT_ERROR at <__gnat_unhandled_exception> (
        e=0x645ff820 <constraint_error>) at s-excdeb.adb:53
    53      s-excdeb.adb: No such file or directory.

At this point, we can already see that something went wrong, since
the frame selected by the debugger corresponds to a runtime function
rather than the function in the user code that caused the exception
to be raised (in our case procedure A).

This is further confirmed by the fact that we are unable to unwind
all the way to procedure A:

    (gdb) bt
    #0  <__gnat_unhandled_exception> (e=0x645ff820 <constraint_error>)
        at s-excdeb.adb:53
    #1  0x000000006444e9a3 in <__gnat_notify_unhandled_exception> (excep=0x284d2
+0)
        at a-exextr.adb:144
    #2  0x00000000645f106a in __gnat_personality_imp ()
       from C:\[...]\libgnat-7.3.dll
    #3  0x000000006144d1b7 in _GCC_specific_handler (ms_exc=0x242fab0,
        this_frame=0x242fe60, ms_orig_context=0x242f5c0, ms_disp=0x242ef70,
        gcc_per=0x645f0960 <__gnat_personality_imp>)
        at ../../../src/libgcc/unwind-seh.c:289
    #4  0x00000000645f1211 in __gnat_personality_seh0 ()
       from C:\[...]\libgnat-7.3.dll
    #5  0x000007fad3879f4d in ?? ()
    Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that the unwinder has been doing its job flawlessly
up until frame #5. The address in frame #5 is correct, but GDB
is not able to associate it with any symbol or unwind record.

And this is because this address is inside ntdll.dll, and when
we received the LOAD_DLL_DEBUG_EVENT for that DLL, the system
was not able to tell us the name of the library, thus causing us
to silently ignoring the event. Because GDB does not know about
ntdll.dll, it is unable to access the unwind information from it.
And because the function at that address does not use a frame
pointer, the unwinding becomes impossible.

This patch helps recovering ntdll.dll at the end of the "run/attach"
phase, simply by trying to locate that specific DLL again.

In terms of our medium to long term planning, it seems to me that
we should be able to simplify the code by ignoring LOAD_DLL_DEBUG_EVENT
during the startup phase, and modify windows_ensure_ntdll_loaded
to then detect and report all shared libraries after we've finished
inferior creation.  But for a change just before 7.7 branch creation,
I thought it was safest to just handle ntdll.dll specifically. This
is less intrusive, and ntdll is the only DLL affected by the problem
I know so far.

gdb/ChangeLog:

	* windows-nat.c (handle_load_dll): Add comments.
        (windows_ensure_ntdll_loaded): New function.
	(do_initial_windows_stuff): Use windows_ensure_ntdll_loaded.
        Add FIXME comment.
GDB/MI: Document support for -exec-run --start in -list-features

This adds "exec-run-start-option" in the output of the -list-features
commands, allowing front-ends to easily determine whether -exec-run
supports the --start option.

gdb/ChangeLog:

        * mi/mi-main.c (mi_cmd_list_features): add "exec-run-start-option".
        * NEWS: Expand the entry documenting the new -exec-run --start
        option to mention the corresponding new entry in the output of
        "-list-features".

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new
	"exec-run-start-option" entry in the output of the "-list-features"
	command.

gdb/testsuite/ChangeLog:

        * gdb.mi/mi-start.exp: Add test verifying that -list-features
        contains "exec-run-start-option".
Set language for Ada minimal symbols.

This helps with the following issue: Given an Ada program defining
a global variable:

    package Pck is
       Watch : Integer := 1974;
    end Pck;

When printing the address of this variable, GDB also tries to print
the associated symbol name:

    (gdb) p watch'address
    $1 = (access integer) 0x6139d8 <pck__watch>
                                       ^^
                                       ||

The problem is that GDB prints the variable's linkage name, instead
of its natural name. This is because the language of the associated
minimal symbol never really gets set.

This patch adds handling for Ada symbols in symbol_find_demangled_name.
After this patch, we now get:

    (gdb) p watch'address
    $1 = (access integer) 0x6139d8 <pck.watch>
                                       ^
                                       |

gdb/ChangeLog:

        * symtab.c (symbol_find_demangled_name): Add handling of
        Ada symbols.

gdb/testsuite/ChangeLog:

        * gdb.ada/int_deref.exp: Add test verifying that we print
        the decoded symbol name when printing the address of Ada
        symbols.
Invalidate target cache before starting to handle event.

gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* infrun.c: Include "target-dcache.h".
	(prepare_for_detach): Call target_dcache_invalidate.
	(wait_for_inferior): Likewise.
	(fetch_inferior_event): Likewise.
	(infrun_thread_stop_requested_callback): Likewise.  Set
	overlay_cache_invalid to 1.
Use target_read_code in skip_prologue (i386)

GDB is able to cache memory accesses requested in target_read_code,
so target_read_code is more efficient than general target_read_memory.

This patch uses target_read_code and its variants to read target
memory in the functions related to i386_skip_prologue.  It improves
the performance when doing 'b foo' (foo is a function) in remote
debugging.

Nowadays, when we set a breakpoint on function f1, GDB will fetch the
code in f1 to determine the start of the function body (say skip the
prologue), it requests read from target many times.  With this patch
applied, the number of RSP 'm' packets are reduced.

gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* corefile.c (read_code): New function.
	(read_code_integer): New function.
	(read_code_unsigned_integer): New function.
	* gdbcore.h (read_code): Declare.
	(read_code_integer): Declare.
	(read_code_unsigned_integer): Declare.
	* i386-tdep.c (i386_follow_jump): Call target_read_code instead
	of target_read_memory.  Call read_code_unsigned_integer instead
	of read_memory_unsigned_integer.
	(i386_analyze_struct_return): Likewise.
	(i386_skip_probe): Likewise.
	(i386_analyze_stack_align): Likewise.
	(i386_match_pattern): Likewise.
	(i386_skip_noop): Likewise.
	(i386_analyze_frame_setup): Likewise.
	(i386_analyze_register_saves): Likewise.
	(i386_skip_prologue): Likewise.
	(i386_skip_main_prologue): Likewise.
	(i386_frame_cache_1): Likewise.
Use target_read_code in skip_prologue (amd64)

gdb:

2013-12-10  Yao Qi  <yao@codesourcery.com>

	* amd64-tdep.c (amd64_analyze_stack_align): Call
	target_read_code instead of target_read_memory.
	(amd64_analyze_prologue): Call read_code_unsigned_integer
	instead of read_memory_unsigned_integer.  Call read_code
	instead of read_memory.
	(amd64_skip_xmm_prologue): Likewise.
Add call to get_compiler_info to gdb_compile_shlib.

    https://sourceware.org/ml/gdb-patches/2013-12/msg00374.html

gdb/testsuite/ChangeLog

	* lib/gdb.exp (gdb_compile_shlib): Add call to get_compiler_info,
	update comment.
daily update
Use $(INSTALL_PROGRAM_ENV) consistently.

binutils/
	* Makefile.am (install-exec-local): Prefix libtool invocation with
	$(INSTALL_PROGRAM_ENV).
	* Makefile.in: Regenerate.

gas/
	* Makefile.am (install-exec-bindir): Prefix libtool invocation
	with $(INSTALL_PROGRAM_ENV).
	(install-exec-tooldir): Likewise.
	* Makefile.in: Regenerate.

gold/
	* Makefile.am (install-exec-local): Prefix $(INSTALL_PROGRAM) uses
	with $(INSTALL_PROGRAM_ENV).
	* Makefile.in: Regenerate.

ld/
	* Makefile.am (install-exec-local): Prefix libtool invocation with
	$(INSTALL_PROGRAM_ENV).
	* Makefile.in: Regenerate.
Delete interp_exec_p.

    	* interps.h (interp_exec_p): Delete.
    	* interps.c (interp_exec_p): Delete.
    	(interp_exec): Update.  Assert interp->procs->exec_proc != NULL.
    	* mi/mi-interp.c (mi_cmd_interpreter_exec): Update.
PR 16286

	* c-lang.c (c_get_string): Ignore the declared size of the object
	if a specific length is requested.

	testsuite/
	* gdb.python/py-value.c: #include stdlib.h, string.h.
	(str): New struct.
	(main): New local xstr.
	* gdb.python/py-value.exp (test_value_in_inferior): Add test to
	fetch a value as a string with a length beyond the declared length
	of the array.
add missing PR# to previous entry
Fix a bug in matching notifications.

Due to copy-n-paste, the problem caused PR remote/15974 also exists
in gdbserver.  This patch fixes it in the same way.  Patch to fix
remote/15974 can be found:

  https://sourceware.org/ml/gdb-patches/2013-12/msg00014.html

gdb/gdbserver:

2013-12-11  Yao Qi  <yao@codesourcery.com>

	* notif.c (handle_notif_ack): Return 0 if no notification
	matches.
Sanitize access to gdbarch on the SDT probe API (and fix ARM bug)

This patch sanitizes the access to gdbarch made by various functions of
the SDT probe API.  Before this patch, gdbarch was being accessed via
the probe's objfile; however, this proved to cause a bug on 32-bit ARM
targets because during the parsing of the probe's arguments the code
needed to access some pseudo-registers of the architecture, and this
information is not fully correct on the objfile's gdbarch.

Basically, the approach taken was to instead pass the current/selected
frame to the parsing and evaluation functions, so that they can extract
the gdbarch directly from the frame.  It solved the ARM bug reported
above, and also contributed to make the API cleaner.

Tested on x86_64 and 32-bit ARM.

2013-12-11  Sergio Durigan Junior  <sergiodj@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Pass selected frame
	to get_probe_argument_count and evaluate_probe_argument.
	* probe.c (get_probe_argument_count): Adjust declaration to accept
	frame.  Pass frame to probe_ops's get_probe_argument_count.
	(evaluate_probe_argument): Likewise, for evaluate_probe_argument.
	(probe_safe_evaluate_at_pc): Pass frame to
	get_probe_argument_count and evaluate_probe_argument.
	* probe.h (struct probe_ops) <get_probe_argument_count,
	evaluate_probe_argument>: Adjust declarations to accept frame.
	(get_probe_argument_count, evaluate_probe_argument): Likewise.
	* solib-svr4.c (solib_event_probe_action): Get current frame.
	Pass it to get_probe_argument_count.
	(svr4_handle_solib_event): Get current frame.  Pass it to
	get_probe_argument_count and evaluate_probe_argument.
	* stap-probe.c (stap_parse_probe_arguments): Adjust declaration to
	accept gdbarch.  Do not obtain it from the probe's objfile.
	(stap_get_probe_argument_count): Adjust declaration to accept
	frame.  Obtain gdbarch from the frame.  Call generic
	can_evaluate_probe_arguments.  Pass gdbarch to
	stap_parse_probe_arguments.
	(stap_get_arg): Adjust declaration to accept gdbarch.  Pass it to
	stap_parse_probe_arguments.
	(stap_evaluate_probe_argument): Adjust declaration to accept
	frame.  Obtain gdbarch from the frame.  Pass gdbarch to
	stap_get_arg.
	(stap_compile_to_ax): Pass agent_expr's gdbarch to stap_get_arg.
	(compute_probe_arg): Obtain gdbarch from frame.  Pass frame to
	get_probe_argument_count and evaluate_probe_argument.
Add a test for --as-needed with symbol versioning

	* ld-elf/shared.exp (build_tests): Add libneeded2a.so,
	libneeded2b.so, libneeded2c.o and needed2.

	* ld-elf/needed2.ver: New file.
	* ld-elf/needed2a.c: Likewise.
	* ld-elf/needed2b.c: Likewise.
	* ld-elf/needed2c.c: Likewise.
Remove shared object from -Ttext-segment

	* ld.texinfo: Remove shared object from -Ttext-segment.
ld/testsuite/ld-aarch64: Fixup IFUNC tests to work on all targets

Make the ifunc-21 and ifunc-22 tests more generic to support
aarch64_be and ELF targets.

ld/testsuite/ChangeLog:

2013-12-11  Will Newton  <will.newton@linaro.org>

	* ld-aarch64/ifunc-21.d: Make test more generic to support
	aarch64_be and ELF targets.
	* ld-aarch64/ifunc-22.d: Likewise.
daily update
	* dwarf2read.c (lookup_dwo_cutu): Include name of dwp file in
	"can't find DWO" warning.
Eliminate UNSUPPORTED_ERROR.

I have a case that could use an exception for "unsupported feature".
I found UNSUPPORTED_ERROR, but looking deeper, I think as is, reusing
it for other things would be fragile.  E.g., if the Python script
sourced by source_script_from_stream triggers any other missing
functionality that would result in UNSUPPORTED_ERROR being propagated
out to source_script_from_stream, that would confuse the error for
Python not being built into GDB.

This patch thus redoes things a little.  Instead of using an exception
for the "No Python" scenario, check whether Python is configured in
before actually trying to source the file.  It adds a new function
instead of using #ifdef HAVE_PYTHON directly, as that is better at
avoiding bitrot, as both Python and !Python paths are visible to the
compiler this way.

Tested on Fedora 17, with and without Python.

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

	* cli/cli-cmds.c (source_script_from_stream) Use have_python
	instead of catching UNSUPPORTED_ERROR.
	* exceptions.h (UNSUPPORTED_ERROR): Delete.
	* python/python.c (source_python_script) [!HAVE_PYTHON]: Internal
	error if called.
	* python/python.h (have_python): New static inline function.