rd_t * make_rd(coap_address_t *peer, coap_pdu_t *pdu) { rd_t *rd; unsigned char *data; coap_opt_iterator_t opt_iter; coap_opt_t *etag; rd = rd_new(); if (!rd) { debug("hnd_get_rd: cannot allocate storage for rd\n"); return NULL; } if (coap_get_data(pdu, &rd->data.length, &data)) { rd->data.s = (unsigned char *)coap_malloc(rd->data.length); if (!rd->data.s) { debug("hnd_get_rd: cannot allocate storage for rd->data\n"); rd_delete(rd); return NULL; } memcpy(rd->data.s, data, rd->data.length); } etag = coap_check_option(pdu, COAP_OPTION_ETAG, &opt_iter); if (etag) { rd->etag_len = min(COAP_OPT_LENGTH(etag), sizeof(rd->etag)); memcpy(rd->etag, COAP_OPT_VALUE(etag), rd->etag_len); } return rd; }
static void kp_activate(mdb_tgt_t *t) { kp_data_t *kp = t->t_data; mdb_prop_postmortem = TRUE; mdb_prop_kernel = FALSE; if (kp->kp_model == PR_MODEL_ILP32) mdb_prop_datamodel = MDB_TGT_MODEL_ILP32; else mdb_prop_datamodel = MDB_TGT_MODEL_LP64; /* * Initialize our rtld_db agent and then iterate over the link map, * instantiating kp_file objects as we go. */ if ((kp->kp_rap = rd_new((struct ps_prochandle *)t)) != NULL) { (void) rd_loadobj_iter(kp->kp_rap, (rl_iter_f *) kp_iter_mapping, t); } else { mdb_warn("unable to initialize rtld_db agent for proc %p\n", (void *)kp->kp_proc); } (void) mdb_tgt_register_dcmds(t, &kp_dcmds[0], MDB_MOD_FORCE); if (kp->kp_map_exec != NULL && kp->kp_map_exec->kpm_file != NULL) mdb_tgt_elf_export(kp->kp_map_exec->kpm_file->kpf_file); else mdb_tgt_elf_export(NULL); }
rd_agent_t * proc_rdagent(struct proc_handle *phdl) { if (phdl->rdap == NULL && phdl->status != PS_UNDEAD && phdl->status != PS_IDLE) { if ((phdl->rdap = rd_new(phdl)) != NULL) { phdl->rdobjs = malloc(sizeof(*phdl->rdobjs) * 64); phdl->rdobjsz = 64; if (phdl->rdobjs == NULL) return (phdl->rdap); rd_loadobj_iter(phdl->rdap, map_iter, phdl); } } return (phdl->rdap); }
rd_agent_t * proc_rdagent(struct proc_handle *phdl) { if (phdl->rdap == NULL && phdl->status != PS_UNDEAD && phdl->status != PS_IDLE) { if ((phdl->rdap = rd_new(phdl)) == NULL) return (NULL); phdl->maparrsz = 64; phdl->mappings = calloc(phdl->maparrsz, sizeof(*phdl->mappings)); if (phdl->mappings == NULL) return (phdl->rdap); if (rd_loadobj_iter(phdl->rdap, map_iter, phdl) != RD_OK) return (NULL); } return (phdl->rdap); }