struct page_probes {
unsigned long page;
- unsigned long offset;
size_t cnt_ip;
us_proc_ip_t *ip;
struct dentry *dentry;
char *path;
int loaded;
+ unsigned long start_addr;
struct hlist_head head; // for page_probes
};
memcpy(obj->ip, ip, sizeof(*obj->ip)*cnt);
obj->cnt_ip = cnt;
obj->page = page;
- obj->offset = 0;
INIT_HLIST_NODE(&obj->node);
}
}
// page_probes
-static void page_p_set_all_kp_addr(struct page_probes *page_p)
+static void page_p_set_all_kp_addr(struct page_probes *page_p, unsigned long start)
{
us_proc_ip_t *ip;
unsigned long addr;
size_t i;
for (i = 0; i < page_p->cnt_ip; ++i) {
ip = &page_p->ip[i];
- addr = ip->offset + page_p->offset;
+ addr = start + page_p->page + ip->offset;
ip->retprobe.kp.addr = ip->jprobe.kp.addr = addr;
-// printk("### pp_set_all_kp_addr: addr=%x\n", addr);
+// printk("### pp_set_all_kp_addr: start=%x, page=%x, offset=%x, addr=%x\n",
+// start, page_p->page, ip->offset, addr);
}
}
hlist_add_head(&page_p->node, &file_p->head);
}
-static struct page_probes *file_p_find_page_p(struct file_probes *file_p, unsigned long page, unsigned long start_addr)
+static struct page_probes *file_p_find_page_p(struct file_probes *file_p, unsigned long page)
{
struct page_probes *pp = NULL;
struct hlist_node *node = NULL;
struct hlist_head *head = &file_p->head;
+ if (file_p->start_addr > page) {
+ printk("ERROR: file_p->start > page\n");
+ return NULL;
+ }
+
+ page -= file_p->start_addr;
+
hlist_for_each_entry(pp, node, head, node) {
- if (start_addr + pp->page == page) {
- pp->offset = start_addr;
+ if (pp->page == page) {
return pp;
}
}
printk("#### min_index=%2u, max_index=%2u, cnt=%2u\n", min_index, max_index, cnt);
for (idx = min_index; idx < max_index; ++idx) {
- ip[idx - min_index].offset = p_ips[idx].offset;
+ ip[idx - min_index].offset = p_ips[idx].offset & ~PAGE_MASK;;
ip[idx - min_index].jprobe = p_ips[idx].jprobe;
ip[idx - min_index].retprobe = p_ips[idx].retprobe;
}
}
page = p_libs->p_ips[0].offset & PAGE_MASK;
+
printk("#### page=%x\n", page);
min_index = 0;
for (k = 0; k < p_libs->ips_count; ++k) {
{
int i;
- printk("### page=%x, offset=%x\n", pp->page, pp->offset);
+ printk("### page=%x\n", pp->page);
for (i = 0; i < pp->cnt_ip; ++i) {
printk("### addr[%2d]=%x, J_addr=%x, R_addr=%x\n",
i, pp->ip[i].offset,
}
}
-static void print_file_probes(const struct file_probes *fp)
+static void print_file_probes(const struct file_probes *file_p)
{
- struct page_probes *pp = NULL;
+ struct page_probes *page_p = NULL;
struct hlist_node *node = NULL;
- struct hlist_head *head = &fp->head;
+ struct hlist_head *head = &file_p->head;
- printk("### d_iname=%s\n", fp->dentry->d_iname);
+ printk("### d_iname=%s, start_addr=%x\n",
+ file_p->dentry->d_iname, file_p->start_addr);
- hlist_for_each_entry(pp, node, head, node) {
- print_page_probes(pp);
+ hlist_for_each_entry(page_p, node, head, node) {
+ print_page_probes(page_p);
}
}
} else {
p++;
}
+
+ file_p->start = vma->vm_start;
file_p->loaded = 1;
- pack_event_info (DYN_LIB_PROBE_ID, RECORD_ENTRY, "dspdd",
- task->tgid, p, vma->vm_start, vma->vm_end-vma->vm_start, app_flag);
+ pack_event_info(DYN_LIB_PROBE_ID, RECORD_ENTRY, "dspdd",
+ task->tgid, p, vma->vm_start,
+ vma->vm_end - vma->vm_start, app_flag);
}
}
int err;
size_t i;
- send_mapping_event(file_p, proc_p, task, vma);
-
// print_page_probes(page_p);
- page_p_set_all_kp_addr(page_p);
+ page_p_set_all_kp_addr(page_p, file_p->start);
for (i = 0; i < page_p->cnt_ip; ++i) {
err = register_usprobe_my(task, mm, &page_p->ip[i]);
if (vma && check_vma(vma)) {
struct file_probes *file_p = proc_p_find_file_p(proc_p, vma);
if(file_p) {
- struct page_probes *page_p = file_p_find_page_p(file_p, page, vma->vm_start);
+ struct page_probes *page_p;
+ send_mapping_event(file_p, proc_p, task, vma);
+ page_p = file_p_find_page_p(file_p, page);
if (page_p) {
register_us_page_probe(page_p, file_p, proc_p, task, mm, vma);
}