/* Hook into inferior_created, solib_loaded, and solib_unloaded observers to track whether we've loaded a version of libspe2 (as static or dynamic library) that provides the __spe_current_active_context variable. */ static void ppc_linux_spe_context_lookup (struct objfile *objfile) { struct bound_minimal_symbol sym; if (!objfile) { spe_context_objfile = NULL; spe_context_lm_addr = 0; spe_context_offset = 0; spe_context_cache_ptid = minus_one_ptid; spe_context_cache_address = 0; return; } sym = lookup_minimal_symbol ("__spe_current_active_context", NULL, objfile); if (sym.minsym) { spe_context_objfile = objfile; spe_context_lm_addr = svr4_fetch_objfile_link_map (objfile); spe_context_offset = BMSYMBOL_VALUE_ADDRESS (sym); spe_context_cache_ptid = minus_one_ptid; spe_context_cache_address = 0; return; } }
CORE_ADDR fbsd_thread_get_local_address(ptid_t ptid, struct objfile *objfile, CORE_ADDR offset) { td_thrhandle_t th; void *address; CORE_ADDR lm; void *lm2; int ret, is_library = (objfile->flags & OBJF_SHARED); if (IS_THREAD (ptid)) { if (!td_thr_tls_get_addr_p) error ("Cannot find thread-local interface in thread_db library."); /* Get the address of the link map for this objfile. */ lm = svr4_fetch_objfile_link_map (objfile); /* Couldn't find link map. Bail out. */ if (!lm) { if (is_library) error ("Cannot find shared library `%s' link_map in dynamic" " linker's module list", objfile->name); else error ("Cannot find executable file `%s' link_map in dynamic" " linker's module list", objfile->name); } ret = td_ta_map_id2thr_p (thread_agent, GET_THREAD(ptid), &th); /* get the address of the variable. */ store_typed_address(&lm2, builtin_type_void_data_ptr, lm); ret = td_thr_tls_get_addr_p (&th, lm2, offset, &address); if (ret != TD_OK) { if (is_library) error ("Cannot find thread-local storage for thread %ld, " "shared library %s:\n%s", (long) GET_THREAD (ptid), objfile->name, thread_db_err_str (ret)); else error ("Cannot find thread-local storage for thread %ld, " "executable file %s:\n%s", (long) GET_THREAD (ptid), objfile->name, thread_db_err_str (ret)); } /* Cast assuming host == target. */ return extract_typed_address(&address, builtin_type_void_data_ptr); } return (0); }