+/* Get the address of the thread local variable in OBJFILE which is
+ stored at OFFSET within the thread local storage for thread PTID. */
+
+static CORE_ADDR
+remote_get_thread_local_address (ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
+{
+ if (remote_protocol_qGetTLSAddr.support != PACKET_DISABLE)
+ {
+ struct remote_state *rs = get_remote_state ();
+ char *buf = alloca (rs->remote_packet_size);
+ char *p = buf;
+ enum packet_result result;
+
+ strcpy (p, "qGetTLSAddr:");
+ p += strlen (p);
+ p += hexnumstr (p, PIDGET (ptid));
+ *p++ = ',';
+ p += hexnumstr (p, offset);
+ *p++ = ',';
+ p += hexnumstr (p, lm);
+ *p++ = '\0';
+
+ putpkt (buf);
+ getpkt (buf, rs->remote_packet_size, 0);
+ result = packet_ok (buf, &remote_protocol_qGetTLSAddr);
+ if (result == PACKET_OK)
+ {
+ ULONGEST result;
+
+ unpack_varlen_hex (buf, &result);
+ return result;
+ }
+ else if (result == PACKET_UNKNOWN)
+ throw_error (TLS_GENERIC_ERROR,
+ _("Remote target doesn't support qGetTLSAddr packet"));
+ else
+ throw_error (TLS_GENERIC_ERROR,
+ _("Remote target failed to process qGetTLSAddr request"));
+ }
+ else
+ throw_error (TLS_GENERIC_ERROR,
+ _("TLS not supported or disabled on this target"));
+ /* Not reached. */
+ return 0;
+}
+