+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-03  Marc Khouzam  <marc.khouzam@ericsson.com>
 
        * cli/cli-logging.c (pop_output_files): Assign targerr to
 
     }
 
   beneath = find_target_beneath (ops);
-  if (beneath->to_get_thread_local_address)
-    return beneath->to_get_thread_local_address (beneath, ptid, lm, offset);
-  else
-    throw_error (TLS_GENERIC_ERROR,
-                _("TLS not supported on this target"));
+  return beneath->to_get_thread_local_address (beneath, ptid, lm, offset);
 }
 
 /* Callback routine used to find a thread based on the TID part of
 
       struct target_ops *target = ¤t_target;
       volatile struct gdb_exception ex;
 
-      while (target && !target->to_get_thread_local_address)
-       target = find_target_beneath (target);
-      if (!target)
-       return 0;
-
       TRY_CATCH (ex, RETURN_MASK_ERROR)
        {
          /* We do not call target_translate_tls_address here, because
 
   tcomplain ();
 }
 
+static CORE_ADDR
+delegate_get_thread_local_address (struct target_ops *self, ptid_t arg1, CORE_ADDR arg2, CORE_ADDR arg3)
+{
+  self = self->beneath;
+  return self->to_get_thread_local_address (self, arg1, arg2, arg3);
+}
+
+static CORE_ADDR
+tdefault_get_thread_local_address (struct target_ops *self, ptid_t arg1, CORE_ADDR arg2, CORE_ADDR arg3)
+{
+  generic_tls_error ();
+}
+
 static enum target_xfer_status 
 delegate_xfer_partial (struct target_ops *self, enum target_object  arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6, ULONGEST *arg7)
 {
     ops->to_get_bookmark = delegate_get_bookmark;
   if (ops->to_goto_bookmark == NULL)
     ops->to_goto_bookmark = delegate_goto_bookmark;
+  if (ops->to_get_thread_local_address == NULL)
+    ops->to_get_thread_local_address = delegate_get_thread_local_address;
   if (ops->to_xfer_partial == NULL)
     ops->to_xfer_partial = delegate_xfer_partial;
   if (ops->to_memory_map == NULL)
   ops->to_make_corefile_notes = dummy_make_corefile_notes;
   ops->to_get_bookmark = tdefault_get_bookmark;
   ops->to_goto_bookmark = tdefault_goto_bookmark;
+  ops->to_get_thread_local_address = tdefault_get_thread_local_address;
   ops->to_xfer_partial = tdefault_xfer_partial;
   ops->to_memory_map = tdefault_memory_map;
   ops->to_flash_erase = tdefault_flash_erase;
 
 
 static void target_info (char *, int);
 
+static void generic_tls_error (void) ATTRIBUTE_NORETURN;
+
 static void default_terminal_info (struct target_ops *, const char *, int);
 
 static int default_watchpoint_addr_within_range (struct target_ops *,
   return 0;
 }
 
+/* Default implementation of to_get_thread_local_address.  */
+
+static void
+generic_tls_error (void)
+{
+  throw_error (TLS_GENERIC_ERROR,
+              _("Cannot find thread-local variables on this target"));
+}
+
 /* Using the objfile specified in OBJFILE, find the address for the
    current thread's thread-local storage with offset OFFSET.  */
 CORE_ADDR
 target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
 {
   volatile CORE_ADDR addr = 0;
-  struct target_ops *target;
-
-  for (target = current_target.beneath;
-       target != NULL;
-       target = target->beneath)
-    {
-      if (target->to_get_thread_local_address != NULL)
-       break;
-    }
+  struct target_ops *target = ¤t_target;
 
-  if (target != NULL
-      && gdbarch_fetch_tls_load_module_address_p (target_gdbarch ()))
+  if (gdbarch_fetch_tls_load_module_address_p (target_gdbarch ()))
     {
       ptid_t ptid = inferior_ptid;
       volatile struct gdb_exception ex;
 
     CORE_ADDR (*to_get_thread_local_address) (struct target_ops *ops,
                                              ptid_t ptid,
                                              CORE_ADDR load_module_addr,
-                                             CORE_ADDR offset);
+                                             CORE_ADDR offset)
+      TARGET_DEFAULT_NORETURN (generic_tls_error ());
 
     /* Request that OPS transfer up to LEN 8-bit bytes of the target's
        OBJECT.  The OFFSET, for a seekable object, specifies the