ip->got_addr = got_addr;
}
-struct us_ip *copy_ip(const struct us_ip *ip)
-{
- struct us_ip *new_ip = create_ip(ip->offset);
-
- if (new_ip == NULL) {
- printk("us_proc_ip_copy: No enough memory\n");
- return NULL;
- }
-
- // jprobe
- set_ip_jp_handler(new_ip, ip->jprobe.pre_entry, ip->jprobe.entry);
-
- // retprobe
- if (ip->flag_retprobe) {
- set_ip_rp_handler(new_ip, ip->retprobe.handler);
- }
-
- return new_ip;
-}
-
struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d)
{
struct us_ip *ip = create_ip(ip_d->offset);
struct us_ip *create_ip(unsigned long offset);
-struct us_ip *copy_ip(const struct us_ip *ip);
struct us_ip *create_ip_by_ip_data(struct ip_data *ip_d);
void free_ip(struct us_ip *ip);
file->page_probes_hash_bits)]);
}
-struct sspt_file *sspt_file_copy(const struct sspt_file *file)
-{
- struct sspt_file *file_out;
-
- if (file == NULL) {
- printk("### WARNING: file_p == NULL\n");
- return NULL;
- }
-
- file_out = kmalloc(sizeof(*file_out), GFP_ATOMIC);
- if (file_out) {
- struct sspt_page *page = NULL;
- struct hlist_node *node = NULL;
- struct hlist_head *head = NULL;
- int i, table_size;
- INIT_LIST_HEAD(&file_out->list);
- file_out->proc = NULL;
- file_out->dentry = file->dentry;
- file_out->name = file->name;
- file_out->loaded = 0;
- file_out->vm_start = 0;
- file_out->vm_end = 0;
-
- file_out->page_probes_hash_bits = file->page_probes_hash_bits;
- table_size = (1 << file_out->page_probes_hash_bits);
-
- file_out->page_probes_table =
- kmalloc(sizeof(*file_out->page_probes_table)*table_size, GFP_ATOMIC);
-
- for (i = 0; i < table_size; ++i) {
- INIT_HLIST_HEAD(&file_out->page_probes_table[i]);
- }
-
- // copy pages
- for (i = 0; i < table_size; ++i) {
- head = &file->page_probes_table[i];
- swap_hlist_for_each_entry(page, node, head, hlist) {
- sspt_add_page(file_out, sspt_page_copy(page));
- }
- }
- }
-
- return file_out;
-}
-
static struct sspt_page *sspt_find_page(struct sspt_file *file, unsigned long offset)
{
struct hlist_node *node;
struct sspt_file *sspt_file_create(char *name, struct dentry *dentry, int page_cnt);
-struct sspt_file *sspt_file_copy(const struct sspt_file *file);
void sspt_file_free(struct sspt_file *file);
struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long page);
list_del(&ip->list);
}
-struct sspt_page *sspt_page_copy(const struct sspt_page *page)
-{
- struct us_ip *ip, *new_ip;
- struct sspt_page *new_page = kmalloc(sizeof(*new_page), GFP_ATOMIC);
-
- if (new_page) {
- INIT_LIST_HEAD(&new_page->ip_list);
- list_for_each_entry(ip, &page->ip_list, list) {
- new_ip = copy_ip(ip);
- if (new_ip == NULL) {
- sspt_page_free(new_page);
- return NULL;
- }
-
- sspt_list_add_ip(new_page, new_ip);
- }
-
- new_page->offset = page->offset;
- new_page->install = 0;
- spin_lock_init(&new_page->lock);
- INIT_HLIST_NODE(&new_page->hlist);
- new_page->file = NULL;
- }
-
- return new_page;
-}
-
void sspt_add_ip(struct sspt_page *page, struct us_ip *ip)
{
struct us_ip *ip_tmp;
};
struct sspt_page *sspt_page_create(unsigned long offset);
-struct sspt_page *sspt_page_copy(const struct sspt_page *page);
void sspt_page_free(struct sspt_page *page);
void sspt_add_ip(struct sspt_page *page, struct us_ip *ip);
sspt_file_add_ip(file, ip_d);
}
-struct sspt_proc *sspt_proc_copy(struct sspt_proc *proc, struct task_struct *task)
-{
- struct sspt_file *file;
- struct sspt_proc *proc_out = sspt_proc_create(task);
-
- list_for_each_entry(file, &proc->file_list, list) {
- sspt_proc_add_file(proc_out, sspt_file_copy(file));
- }
-
- return proc_out;
-}
-
struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *dentry)
{
struct sspt_file *file;
struct sspt_proc *sspt_proc_create(struct task_struct *task);
-struct sspt_proc *sspt_proc_copy(struct sspt_proc *proc, struct task_struct *task);
void sspt_proc_free(struct sspt_proc *proc);
struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task);