Exemplo n.º 1
0
int Psymbol_iter_by_addr(struct ps_prochandle *P, const char *object_name, int which, int mask, proc_sym_f *func, void *cd)
{
    prmap_t *map ;
    struct lookup_uc uc;
    proc_mod_t *mod = findmodulebyname(P, object_name);
    /* this fails miserable - dtrace -n pid$target:user32:N*:entry pid$target:M*::entry -c exe
      the second probe spec will be ignored */
    if (mod == NULL || mod->loaded_order < P->dll_load_order)
        return 0;

    if (strcmp("a.out", object_name) == 0)
        map = Plmid_to_map(P, 0, P->exe_module->name);
    else
        map = Plmid_to_map(P, 0, object_name);

    if (map == NULL) {
        return -1;
    }

    uc.f = func;
    uc.cd = cd;
    uc.ps = P;
    uc.count = 0;

    if (SymEnumSymbols(P->phandle, mod->imgbase, NULL, SymEnumSymbolsProc, &uc) == FALSE) {
        dprintf("Psymbol_iter_by_addr: SymEnumSymbols failed %s: %x\n", object_name, GetLastError());
        return -1;
    }

    if (uc.count != 0)
        return 0;

    return dw_iter_by_addr(P, object_name, which, mask, func, cd);
}
Exemplo n.º 2
0
prmap_t *
Pname_to_map(struct ps_prochandle *p, const char *name)
{
    if (strcmp("a.out", name) == 0)
        return Plmid_to_map(p, 0, p->exe_module->name);
    else
        return Plmid_to_map(p, 0, name);
}
Exemplo n.º 3
0
static const prmap_t *
dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P)
{
	char m[MAXPATHLEN];
#if defined(sun)
	Lmid_t lmid = PR_LMID_EVERY;
#else
	Lmid_t lmid = 0;
#endif
	const char *obj;
	const prmap_t *pmp;

#if defined(sun)
	/*
	 * Pick apart the link map from the library name.
	 */
	if (strchr(pdp->dtpd_mod, '`') != NULL) {
		char *end;

		if (strncmp(pdp->dtpd_mod, "LM", 2) != 0 ||
		    !isdigit(pdp->dtpd_mod[2]))
			return (NULL);

		lmid = strtoul(&pdp->dtpd_mod[2], &end, 16);

		obj = end + 1;

		if (*end != '`' || strchr(obj, '`') != NULL)
			return (NULL);

	} else {
		obj = pdp->dtpd_mod;
	}
#else
	obj = pdp->dtpd_mod;
#endif

	if ((pmp = Plmid_to_map(P, lmid, obj)) == NULL)
		return (NULL);

#if defined(sun)
	(void) Pobjname(P, pmp->pr_vaddr, m, sizeof (m));
	if ((obj = strrchr(m, '/')) == NULL)
		obj = &m[0];
	else
		obj++;

	(void) Plmid(P, pmp->pr_vaddr, &lmid);
#endif

	dt_pid_objname(pdp->dtpd_mod, sizeof (pdp->dtpd_mod), lmid, obj);

	return (pmp);
}