2 * Dynamic Binary Instrumentation Module based on KProbes
3 * modules/driver/sspt/ip.c
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Copyright (C) Samsung Electronics, 2013
21 * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
25 #include <linux/slab.h>
26 #include <linux/module.h>
28 #include "sspt_page.h"
29 #include "sspt_file.h"
30 #include <us_manager/probes/use_probes.h>
33 * @brief Create us_ip struct
35 * @param page User page
36 * @param offset Function offset from the beginning of the page
37 * @param probe_i Pointer to the probe data.
38 * @param page Pointer to the parent sspt_page struct
39 * @return Pointer to the created us_ip struct
41 struct us_ip *create_ip(unsigned long offset, const struct probe_info *info,
42 struct sspt_page *page)
45 struct probe_info *info_new;
47 info_new = probe_info_dup(info);
48 if (info_new == NULL) {
49 printk("Cannot probe_info_dup in %s function!\n", __func__);
53 ip = kmalloc(sizeof(*ip), GFP_ATOMIC);
55 memset(ip, 0, sizeof(*ip));
57 INIT_LIST_HEAD(&ip->list);
61 probe_info_copy(info, info_new);
62 probe_info_init(info_new, ip);
65 printk(KERN_INFO "Cannot kmalloc in create_ip function!\n");
66 probe_info_free(info_new);
73 * @brief Remove us_ip struct
75 * @param ip remove object
78 void free_ip(struct us_ip *ip)
80 probe_info_uninit(ip->info, ip);
81 probe_info_free(ip->info);