+/* Implement the get_thread_local_address gdbarch method. */
+
+static CORE_ADDR
+i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
+ CORE_ADDR lm_addr, CORE_ADDR offset)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ struct regcache *regcache;
+
+ if (tdep->fsbase_regnum == -1)
+ error (_("Unable to fetch %%gsbase"));
+
+ regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
+ ptid, gdbarch);
+
+ target_fetch_registers (regcache, tdep->fsbase_regnum + 1);
+
+ ULONGEST gsbase;
+ if (regcache->cooked_read (tdep->fsbase_regnum + 1, &gsbase) != REG_VALID)
+ error (_("Unable to fetch %%gsbase"));
+
+ CORE_ADDR dtv_addr = gsbase + gdbarch_ptr_bit (gdbarch) / 8;
+ return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset);
+}
+