summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>2014-07-08 17:37:30 +0400
committerDmitry Kovalenko <d.kovalenko@samsung.com>2014-07-11 03:57:49 -0700
commit84721ae959c23f8a7ac0e4eff776cd67cee91738 (patch)
tree9dea837ab0634e16c0f74f1096f3474ced30fd24
parent717d856794e771e21bd506eb45156f6b609f345e (diff)
downloadswap-modules-84721ae959c23f8a7ac0e4eff776cd67cee91738.tar.gz
swap-modules-84721ae959c23f8a7ac0e4eff776cd67cee91738.tar.bz2
swap-modules-84721ae959c23f8a7ac0e4eff776cd67cee91738.zip
[STYLE] us_manager: doxygen comments
Change-Id: I00ab2816a2ccb632f67144e004619e55b99cfd3f Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
-rw-r--r--us_manager/debugfs_us_manager.c10
-rw-r--r--us_manager/debugfs_us_manager.h32
-rw-r--r--us_manager/helper.c25
-rw-r--r--us_manager/helper.h11
-rw-r--r--us_manager/img/img_file.c43
-rw-r--r--us_manager/img/img_file.h20
-rw-r--r--us_manager/img/img_ip.c21
-rw-r--r--us_manager/img/img_ip.h22
-rw-r--r--us_manager/img/img_proc.c36
-rw-r--r--us_manager/img/img_proc.h17
-rw-r--r--us_manager/pf/pf_group.c95
-rw-r--r--us_manager/pf/pf_group.h11
-rw-r--r--us_manager/pf/proc_filters.c55
-rw-r--r--us_manager/pf/proc_filters.h27
-rw-r--r--us_manager/sspt/ip.c14
-rw-r--r--us_manager/sspt/ip.h29
-rw-r--r--us_manager/sspt/sspt_feature.c31
-rw-r--r--us_manager/sspt/sspt_feature.h15
-rw-r--r--us_manager/sspt/sspt_file.c71
-rw-r--r--us_manager/sspt/sspt_file.h33
-rw-r--r--us_manager/sspt/sspt_page.c48
-rw-r--r--us_manager/sspt/sspt_page.h27
-rw-r--r--us_manager/sspt/sspt_proc.c117
-rw-r--r--us_manager/sspt/sspt_proc.h36
-rw-r--r--us_manager/us_manager.c32
-rw-r--r--us_manager/us_manager.h21
-rw-r--r--us_manager/us_slot_manager.c12
-rw-r--r--us_manager/us_slot_manager.h11
28 files changed, 798 insertions, 124 deletions
diff --git a/us_manager/debugfs_us_manager.c b/us_manager/debugfs_us_manager.c
index 84a01396..c18f8374 100644
--- a/us_manager/debugfs_us_manager.c
+++ b/us_manager/debugfs_us_manager.c
@@ -75,6 +75,11 @@ static const struct file_operations fops_tasks = {
static struct dentry *us_manager_dir = NULL;
+/**
+ * @brief Destroy debugfs for us_manager
+ *
+ * @return Void
+ */
void exit_debugfs_us_manager(void)
{
if (us_manager_dir)
@@ -83,6 +88,11 @@ void exit_debugfs_us_manager(void)
us_manager_dir = NULL;
}
+/**
+ * @brief Create debugfs for us_manager
+ *
+ * @return Error code
+ */
int init_debugfs_us_manager(void)
{
struct dentry *swap_dir, *dentry;
diff --git a/us_manager/debugfs_us_manager.h b/us_manager/debugfs_us_manager.h
index 52a5bda3..11c281be 100644
--- a/us_manager/debugfs_us_manager.h
+++ b/us_manager/debugfs_us_manager.h
@@ -1,7 +1,39 @@
#ifndef __DEBUGFS_US_MANAGER_H__
#define __DEBUGFS_US_MANAGER_H__
+/**
+ * @file us_manager/debugfs_us_manager.h
+ * @author Alexander Aksenov <a.aksenov@samsung.com>
+ *
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * @section COPYRIGHT
+ * Copyright (C) Samsung Electronics, 2014
+ */
+
+/**
+ * @def US_MANAGER_DFS_DIR @hideinitializer
+ * Name in debugfs
+ */
#define US_MANAGER_DFS_DIR "us_manager"
+
+/**
+ * @def US_MANAGER_DFS_DIR @hideinitializer
+ * Name in debugfs
+ */
#define US_MANAGER_TASKS "tasks"
int init_debugfs_us_manager(void);
diff --git a/us_manager/helper.c b/us_manager/helper.c
index 2ecbe42c..6dbb8c08 100644
--- a/us_manager/helper.c
+++ b/us_manager/helper.c
@@ -546,6 +546,11 @@ static void unregister_comm(void)
+/**
+ * @brief Registration of helper
+ *
+ * @return Error code
+ */
int register_helper(void)
{
int ret = 0;
@@ -620,6 +625,11 @@ unreg_comm:
return ret;
}
+/**
+ * @brief Unegistration of helper bottom
+ *
+ * @return Void
+ */
void unregister_helper_top(void)
{
#ifdef CONFIG_ARM
@@ -629,6 +639,11 @@ void unregister_helper_top(void)
atomic_set(&stop_flag, 1);
}
+/**
+ * @brief Unegistration of helper top
+ *
+ * @return Void
+ */
void unregister_helper_bottom(void)
{
unregister_mmap();
@@ -638,6 +653,11 @@ void unregister_helper_bottom(void)
unregister_comm();
}
+/**
+ * @brief Initialization of helper
+ *
+ * @return Error code
+ */
int init_helper(void)
{
unsigned long addr;
@@ -701,6 +721,11 @@ int init_helper(void)
return 0;
}
+/**
+ * @brief Uninitialization of helper
+ *
+ * @return Void
+ */
void uninit_helper(void)
{
}
diff --git a/us_manager/helper.h b/us_manager/helper.h
index d8933717..475195d0 100644
--- a/us_manager/helper.h
+++ b/us_manager/helper.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/helper.h
+/**
+ * @file us_manager/helper.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
#ifndef _HELPER_H
diff --git a/us_manager/img/img_file.c b/us_manager/img/img_file.c
index db5c6de8..6a2d4052 100644
--- a/us_manager/img/img_file.c
+++ b/us_manager/img/img_file.c
@@ -31,6 +31,12 @@
static void img_del_ip_by_list(struct img_ip *ip);
+/**
+ * @brief Create img_file struct
+ *
+ * @param dentry Dentry of file
+ * @return Pointer to the created img_file struct
+ */
struct img_file *create_img_file(struct dentry *dentry)
{
struct img_file *file;
@@ -43,6 +49,12 @@ struct img_file *create_img_file(struct dentry *dentry)
return file;
}
+/**
+ * @brief Remove img_file struct
+ *
+ * @param file remove object
+ * @return Void
+ */
void free_img_file(struct img_file *file)
{
struct img_ip *ip, *tmp;
@@ -77,6 +89,15 @@ static struct img_ip *find_img_ip(struct img_file *file, unsigned long addr)
return NULL;
}
+/**
+ * @brief Add instrumentation pointer
+ *
+ * @param file Pointer to the img_file struct
+ * @param addr Function address
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Error code
+ */
int img_file_add_ip(struct img_file *file, unsigned long addr,
const char *args, char ret_type)
{
@@ -94,6 +115,13 @@ int img_file_add_ip(struct img_file *file, unsigned long addr,
return 0;
}
+/**
+ * @brief Delete img_ip struct from img_file struct
+ *
+ * @param file Pointer to the img_file struct
+ * @param addr Function address
+ * @return Error code
+ */
int img_file_del_ip(struct img_file *file, unsigned long addr)
{
struct img_ip *ip;
@@ -109,11 +137,26 @@ int img_file_del_ip(struct img_file *file, unsigned long addr)
return 0;
}
+/**
+ * @brief Check on absence img_ip structs in img_file struct
+ *
+ * @param file Pointer to the img_file struct
+ * @return
+ * - 0 - not empty
+ * - 1 - empty
+ */
int img_file_empty(struct img_file *file)
{
return list_empty(&file->ip_list);
}
+/**
+ * @brief For debug
+ *
+ * @param file Pointer to the img_file struct
+ * @return Void
+ */
+
/* debug */
void img_file_print(struct img_file *file)
{
diff --git a/us_manager/img/img_file.h b/us_manager/img/img_file.h
index c5f82fa4..312313da 100644
--- a/us_manager/img/img_file.h
+++ b/us_manager/img/img_file.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/img/img_file.h
+/**
+ * @file us_manager/img/img_file.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
*
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
@@ -28,10 +28,14 @@
#include <linux/types.h>
+/**
+ * @struct img_file
+ * @breaf Image of file
+ */
struct img_file {
- struct list_head list; /* for img_proc */
- struct dentry *dentry;
- struct list_head ip_list; /* for img_ip */
+ struct list_head list; /**< For img_proc */
+ struct dentry *dentry; /**< Dentry of file */
+ struct list_head ip_list; /**< For img_ip */
};
struct img_file *create_img_file(struct dentry *dentry);
diff --git a/us_manager/img/img_ip.c b/us_manager/img/img_ip.c
index 4f214c30..102d9f08 100644
--- a/us_manager/img/img_ip.c
+++ b/us_manager/img/img_ip.c
@@ -26,6 +26,14 @@
#include "img_ip.h"
#include <linux/slab.h>
+/**
+ * @brief Create img_ip struct
+ *
+ * @param addr Function address
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Pointer to the created img_ip struct
+ */
struct img_ip *create_img_ip(unsigned long addr, const char *args,
char ret_type)
{
@@ -46,12 +54,25 @@ struct img_ip *create_img_ip(unsigned long addr, const char *args,
return ip;
}
+/**
+ * @brief Remove img_ip struct
+ *
+ * @param ip remove object
+ * @return Void
+ */
void free_img_ip(struct img_ip *ip)
{
kfree(ip->args);
kfree(ip);
}
+/**
+ * @brief For debug
+ *
+ * @param ip Pointer to the img_ip struct
+ * @return Void
+ */
+
/* debug */
void img_ip_print(struct img_ip *ip)
{
diff --git a/us_manager/img/img_ip.h b/us_manager/img/img_ip.h
index a3676be3..a6992f75 100644
--- a/us_manager/img/img_ip.h
+++ b/us_manager/img/img_ip.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/img/img_ip.h
+/**
+ * @file us_manager/img/img_ip.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
*
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
@@ -28,11 +28,15 @@
#include <linux/types.h>
+/**
+ * @struct img_ip
+ * @breaf Image of instrumentation pointer
+ */
struct img_ip {
- struct list_head list; /* for img_file */
- unsigned long addr;
- char *args;
- char ret_type;
+ struct list_head list; /**< For img_file */
+ unsigned long addr; /**< Function address */
+ char *args; /**< Function arguments */
+ char ret_type; /**< Return type */
};
struct img_ip *create_img_ip(unsigned long addr, const char *args,
diff --git a/us_manager/img/img_proc.c b/us_manager/img/img_proc.c
index 3483832d..ce7749ae 100644
--- a/us_manager/img/img_proc.c
+++ b/us_manager/img/img_proc.c
@@ -29,6 +29,11 @@
static void img_del_file_by_list(struct img_file *file);
+/**
+ * @brief Create img_proc struct
+ *
+ * @return Pointer to the created img_proc struct
+ */
struct img_proc *create_img_proc(void)
{
struct img_proc *proc;
@@ -39,6 +44,12 @@ struct img_proc *create_img_proc(void)
return proc;
}
+/**
+ * @brief Remove img_proc struct
+ *
+ * @param file remove object
+ * @return Void
+ */
void free_img_proc(struct img_proc *ip)
{
struct img_file *file, *tmp;
@@ -73,6 +84,16 @@ static struct img_file *find_img_file(struct img_proc *proc, struct dentry *dent
return NULL;
}
+/**
+ * @brief Add instrumentation pointer
+ *
+ * @param proc Pointer to the img_proc struct
+ * @param dentry Dentry of file
+ * @param addr Function address
+ * @param args Function address
+ * @param ret_type Return type
+ * @return Error code
+ */
int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry,
unsigned long addr, const char *args, char ret_type)
{
@@ -96,6 +117,14 @@ int img_proc_add_ip(struct img_proc *proc, struct dentry *dentry,
return ret;
}
+/**
+ * @brief Remove instrumentation pointer
+ *
+ * @param proc Pointer to the img_proc struct
+ * @param dentry Dentry of file
+ * @param args Function address
+ * @return Error code
+ */
int img_proc_del_ip(struct img_proc *proc, struct dentry *dentry, unsigned long addr)
{
int ret;
@@ -114,6 +143,13 @@ int img_proc_del_ip(struct img_proc *proc, struct dentry *dentry, unsigned long
return ret;
}
+/**
+ * @brief For debug
+ *
+ * @param proc Pointer to the img_proc struct
+ * @return Void
+ */
+
/* debug */
void img_proc_print(struct img_proc *proc)
{
diff --git a/us_manager/img/img_proc.h b/us_manager/img/img_proc.h
index 7da2b0d1..a1b71d58 100644
--- a/us_manager/img/img_proc.h
+++ b/us_manager/img/img_proc.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/img_proc.h
+/**
+ * @file us_manager/img/img_proc.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENCE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
@@ -30,8 +29,12 @@
struct dentry;
+/**
+ * @struct img_proc
+ * @breaf Image of process
+ */
struct img_proc {
- struct list_head file_list;
+ struct list_head file_list; /**< For img_file */
};
struct img_proc *create_img_proc(void);
diff --git a/us_manager/pf/pf_group.c b/us_manager/pf/pf_group.c
index d326f19e..ad26bc04 100644
--- a/us_manager/pf/pf_group.c
+++ b/us_manager/pf/pf_group.c
@@ -172,6 +172,13 @@ static void del_pfg_by_list(struct pf_group *pfg)
list_del(&pfg->list);
}
+/**
+ * @brief Get pf_group struct by dentry
+ *
+ * @param dentry Dentry of file
+ * @param priv Private data
+ * @return Pointer on pf_group struct
+ */
struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv)
{
struct pf_group *pfg;
@@ -193,6 +200,13 @@ struct pf_group *get_pf_group_by_dentry(struct dentry *dentry, void *priv)
}
EXPORT_SYMBOL_GPL(get_pf_group_by_dentry);
+/**
+ * @brief Get pf_group struct by TGID
+ *
+ * @param tgid Thread group ID
+ * @param priv Private data
+ * @return Pointer on pf_group struct
+ */
struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
{
struct pf_group *pfg;
@@ -214,6 +228,12 @@ struct pf_group *get_pf_group_by_tgid(pid_t tgid, void *priv)
}
EXPORT_SYMBOL_GPL(get_pf_group_by_tgid);
+/**
+ * @brief Get pf_group struct for each process
+ *
+ * @param priv Private data
+ * @return Pointer on pf_group struct
+ */
struct pf_group *get_pf_group_dumb(void *priv)
{
struct pf_group *pfg;
@@ -235,11 +255,27 @@ struct pf_group *get_pf_group_dumb(void *priv)
}
EXPORT_SYMBOL_GPL(get_pf_group_dumb);
+/**
+ * @brief Put pf_group struct
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @return Void
+ */
void put_pf_group(struct pf_group *pfg)
{
}
+/**
+ * @brief Register prober for pf_grpup struct
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @param dentry Dentry of file
+ * @param offset Function offset
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Error code
+ */
int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
unsigned long offset, const char *args, char ret_type)
{
@@ -247,6 +283,14 @@ int pf_register_probe(struct pf_group *pfg, struct dentry *dentry,
}
EXPORT_SYMBOL_GPL(pf_register_probe);
+/**
+ * @brief Unregister prober from pf_grpup struct
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @param dentry Dentry of file
+ * @param offset Function offset
+ * @return Error code
+ */
int pf_unregister_probe(struct pf_group *pfg, struct dentry *dentry,
unsigned long offset)
{
@@ -254,6 +298,14 @@ int pf_unregister_probe(struct pf_group *pfg, struct dentry *dentry,
}
EXPORT_SYMBOL_GPL(pf_unregister_probe);
+/**
+ * @brief Check the task, to meet the filter criteria
+ *
+ * @prarm task Pointer on the task_struct struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_task_on_filters(struct task_struct *task)
{
struct pf_group *pfg;
@@ -266,6 +318,13 @@ int check_task_on_filters(struct task_struct *task)
return 0;
}
+/**
+ * @brief Check task and install probes on demand
+ *
+ * @prarm task Pointer on the task_struct struct
+ * @param page_addr Page fault address
+ * @return Void
+ */
void call_page_fault(struct task_struct *task, unsigned long page_addr)
{
struct pf_group *pfg, *pfg_first = NULL;
@@ -321,6 +380,13 @@ void call_page_fault(struct task_struct *task, unsigned long page_addr)
}
}
+/**
+ * @brief Uninstall probes from the sspt_proc struct
+ *
+ * @prarm proc Pointer on the sspt_proc struct
+ * @return Void
+ */
+
/* called with sspt_proc_write_lock() */
void uninstall_proc(struct sspt_proc *proc)
{
@@ -344,6 +410,12 @@ void uninstall_proc(struct sspt_proc *proc)
sspt_proc_free(proc);
}
+/**
+ * @brief Remove probes from the task on demand
+ *
+ * @prarm task Pointer on the task_struct struct
+ * @return Void
+ */
void call_mm_release(struct task_struct *task)
{
struct sspt_proc *proc;
@@ -358,11 +430,22 @@ void call_mm_release(struct task_struct *task)
sspt_proc_write_unlock();
}
+/**
+ * @brief Legacy code, it is need remove
+ *
+ * @param addr Page address
+ * @return Void
+ */
void uninstall_page(unsigned long addr)
{
}
+/**
+ * @brief Install probes on running processes
+ *
+ * @return Void
+ */
void install_all(void)
{
#if !defined(CONFIG_ARM)
@@ -401,6 +484,11 @@ static void on_each_uninstall_proc(struct sspt_proc *proc, void *data)
uninstall_proc(proc);
}
+/**
+ * @brief Uninstall probes from all processes
+ *
+ * @return Void
+ */
void uninstall_all(void)
{
sspt_proc_write_lock();
@@ -410,6 +498,13 @@ void uninstall_all(void)
clean_pfg();
}
+/**
+ * @brief For debug
+ *
+ * @param pfg Pointer to the pf_group struct
+ * @return Void
+ */
+
/* debug */
void pfg_print(struct pf_group *pfg)
{
diff --git a/us_manager/pf/pf_group.h b/us_manager/pf/pf_group.h
index 6f513389..67d4c1e6 100644
--- a/us_manager/pf/pf_group.h
+++ b/us_manager/pf/pf_group.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/pf/pf_group.h
+/**
+ * @file us_manager/pf/pf_group.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
diff --git a/us_manager/pf/proc_filters.c b/us_manager/pf/proc_filters.c
index 66757a4f..7efccdad 100644
--- a/us_manager/pf/proc_filters.c
+++ b/us_manager/pf/proc_filters.c
@@ -77,6 +77,14 @@ static struct task_struct *call_dumb(struct proc_filter *self,
return task;
}
+/**
+ * @brief Filling pf_group struct by dentry
+ *
+ * @param pf Pointer to the proc_filter struct
+ * @param dentry Dentry
+ * @param priv Private data
+ * @return Void
+ */
void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry, void *priv)
{
pf->call = &call_by_dentry;
@@ -84,6 +92,14 @@ void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry, void *priv)
pf->priv = priv;
}
+/**
+ * @brief Filling pf_group struct by TGID
+ *
+ * @param pf Pointer to the proc_filter struct
+ * @param tgid Thread group ID
+ * @param priv Private data
+ * @return Void
+ */
void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv)
{
pf->call = &call_by_tgid;
@@ -91,6 +107,13 @@ void set_pf_by_tgid(struct proc_filter *pf, pid_t tgid, void *priv)
pf->priv = priv;
}
+/**
+ * @brief Filling pf_group struct for each process
+ *
+ * @param pf Pointer to the proc_filter struct
+ * @param priv Private data
+ * @return Void
+ */
void set_pf_dumb(struct proc_filter *pf, void *priv)
{
pf->call = &call_dumb;
@@ -98,22 +121,54 @@ void set_pf_dumb(struct proc_filter *pf, void *priv)
pf->priv = priv;
}
+/**
+ * @brief Check pf_group struct by dentry
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @param dentry Dentry
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_pf_by_dentry(struct proc_filter *filter, struct dentry *dentry)
{
return filter->data == (void *)dentry &&
filter->call == &call_by_dentry;
}
+/**
+ * @brief Check pf_group struct by TGID
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @param tgid Thread group ID
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_pf_by_tgid(struct proc_filter *filter, pid_t tgid)
{
return filter->data == (void *)tgid && filter->call == &call_by_tgid;
}
+/**
+ * @brief Dumb check always true if filter is a dumb one
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int check_pf_dumb(struct proc_filter *filter)
{
return filter->call == &call_dumb;
}
+/**
+ * @brief Get dentry from pf_group struct if it filter by dentry
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @return Pointer to the dentry struct or NULL
+ */
struct dentry *get_dentry_by_pf(struct proc_filter *filter)
{
if (filter->call == &call_by_dentry)
diff --git a/us_manager/pf/proc_filters.h b/us_manager/pf/proc_filters.h
index 8c0e0102..730f9d50 100644
--- a/us_manager/pf/proc_filters.h
+++ b/us_manager/pf/proc_filters.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/pf/proc_filters.h
+/**
+ * @file us_manager/pf/proc_filters.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
@@ -31,13 +30,25 @@
struct dentry;
struct task_struct;
+/**
+ * @struct proc_filter
+ * @breaf Filter for process
+ */
struct proc_filter {
+ /** Callback for filtering */
struct task_struct *(*call)(struct proc_filter *self,
struct task_struct *task);
- void *data;
- void *priv;
+ void *data; /**< Data of callback */
+ void *priv; /**< Private data */
};
+/**
+ * @def check_task_f @hideinitializer
+ * Call filter on the task
+ *
+ * @param filter Pointer to the proc_filter struct
+ * @param task Pointer to the task_struct struct
+ */
#define check_task_f(filter, task) (filter)->call(filter, task)
void set_pf_by_dentry(struct proc_filter *pf, struct dentry *dentry,
diff --git a/us_manager/sspt/ip.c b/us_manager/sspt/ip.c
index d21856e1..c7779cec 100644
--- a/us_manager/sspt/ip.c
+++ b/us_manager/sspt/ip.c
@@ -60,6 +60,14 @@ static int ret_handler(struct uretprobe_instance *ri, struct pt_regs *regs)
return 0;
}
+/**
+ * @brief Create us_ip struct
+ *
+ * @param offset Function offset from the beginning of the page
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Pointer to the created us_ip struct
+ */
struct us_ip *create_ip(unsigned long offset, const char *args, char ret_type)
{
size_t len = strlen(args) + 1;
@@ -86,6 +94,12 @@ struct us_ip *create_ip(unsigned long offset, const char *args, char ret_type)
return ip;
}
+/**
+ * @brief Remove us_ip struct
+ *
+ * @param ip remove object
+ * @return Void
+ */
void free_ip(struct us_ip *ip)
{
kfree(ip);
diff --git a/us_manager/sspt/ip.h b/us_manager/sspt/ip.h
index c2a12ab6..6ceb3d1c 100644
--- a/us_manager/sspt/ip.h
+++ b/us_manager/sspt/ip.h
@@ -1,10 +1,11 @@
#ifndef __IP__
#define __IP__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/ip.h
+/**
+ * @file us_manager/sspt/ip.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -19,10 +20,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include <linux/list.h>
@@ -30,16 +29,20 @@
struct sspt_page;
+/**
+ * @struct us_ip
+ * @breaf Image of instrumentation pointer for specified process
+ */
struct us_ip {
- struct list_head list;
- struct sspt_page *page;
+ struct list_head list; /**< For sspt_page */
+ struct sspt_page *page; /**< Pointer on the page (parent) */
- struct uretprobe retprobe;
- char *args;
- char ret_type;
- unsigned long orig_addr;
+ struct uretprobe retprobe; /**< uretprobe */
+ char *args; /**< Function arguments */
+ char ret_type; /**< Return type */
+ unsigned long orig_addr; /**< Function address */
- unsigned long offset;
+ unsigned long offset; /**< Page offset */
};
diff --git a/us_manager/sspt/sspt_feature.c b/us_manager/sspt/sspt_feature.c
index 80d20945..98e0b6bd 100644
--- a/us_manager/sspt/sspt_feature.c
+++ b/us_manager/sspt/sspt_feature.c
@@ -71,6 +71,11 @@ static void destroy_feature_data(struct sspt_feature_data *fd)
kfree(fd);
}
+/**
+ * @brief Create sspt_feature struct
+ *
+ * @return Pointer to the created sspt_feature struct
+ */
struct sspt_feature *sspt_create_feature(void)
{
struct sspt_feature *f;
@@ -96,6 +101,12 @@ struct sspt_feature *sspt_create_feature(void)
return f;
}
+/**
+ * @brief Destroy sspt_feature struct
+ *
+ * @param f remove object
+ * @return Void
+ */
void sspt_destroy_feature(struct sspt_feature *f)
{
struct sspt_feature_data *fd, *n;
@@ -171,6 +182,13 @@ static void del_feature_from_proc(struct sspt_proc *proc, void *data)
del_feature_by_img(proc->feature, (struct sspt_feature_img *)data);
}
+/**
+ * @brief Get data for feature
+ *
+ * @param f Pointer to the sspt_feature struct
+ * @param id Feature ID
+ * @return Pointer to the data
+ */
void *sspt_get_feature_data(struct sspt_feature *f, sspt_feature_id_t id)
{
struct sspt_feature_img *img = (struct sspt_feature_img *)id;
@@ -185,6 +203,13 @@ void *sspt_get_feature_data(struct sspt_feature *f, sspt_feature_id_t id)
}
EXPORT_SYMBOL_GPL(sspt_get_feature_data);
+/**
+ * @brief Register sspt feature
+ *
+ * @param alloc Callback for allocating data
+ * @param free Callback to release data
+ * @return Feature ID
+ */
sspt_feature_id_t sspt_register_feature(void *(*alloc)(void), void (*free)(void *data))
{
struct sspt_feature_img *fi;
@@ -197,6 +222,12 @@ sspt_feature_id_t sspt_register_feature(void *(*alloc)(void), void (*free)(void
}
EXPORT_SYMBOL_GPL(sspt_register_feature);
+/**
+ * @brief Unregister sspt feature
+ *
+ * @param id Feature ID
+ * @return Void
+ */
void sspt_unregister_feature(sspt_feature_id_t id)
{
struct sspt_feature_img *fi = (struct sspt_feature_img *)id;
diff --git a/us_manager/sspt/sspt_feature.h b/us_manager/sspt/sspt_feature.h
index ca372edd..667f3dc8 100644
--- a/us_manager/sspt/sspt_feature.h
+++ b/us_manager/sspt/sspt_feature.h
@@ -1,10 +1,11 @@
#ifndef _SSPT_FEATUER_H
#define _SSPT_FEATUER_H
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/us_manager/sspt/sspt_feature.h
+/**
+ * @file us_manager/sspt/sspt_feature.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -19,16 +20,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
struct sspt_feature;
-typedef void * sspt_feature_id_t;
-#define SSPT_FEATURE_ID_BAD NULL
+typedef void * sspt_feature_id_t; /**< @brief sspt feature ID type */
+#define SSPT_FEATURE_ID_BAD NULL /**< @def SSPT_FEATURE_ID_BAD */
struct sspt_feature *sspt_create_feature(void);
void sspt_destroy_feature(struct sspt_feature *f);
diff --git a/us_manager/sspt/sspt_file.c b/us_manager/sspt/sspt_file.c
index 95398449..c4875503 100644
--- a/us_manager/sspt/sspt_file.c
+++ b/us_manager/sspt/sspt_file.c
@@ -40,6 +40,13 @@ static int calculation_hash_bits(int cnt)
return bits;
}
+/**
+ * @brief Create sspt_file struct
+ *
+ * @param dentry Dentry of file
+ * @param page_cnt Size of hash-table
+ * @return Pointer to the created sspt_file struct
+ */
struct sspt_file *sspt_file_create(struct dentry *dentry, int page_cnt)
{
struct sspt_file *obj = kmalloc(sizeof(*obj), GFP_ATOMIC);
@@ -66,6 +73,12 @@ struct sspt_file *sspt_file_create(struct dentry *dentry, int page_cnt)
return obj;
}
+/**
+ * @brief Remove sspt_file struct
+ *
+ * @param file remove object
+ * @return Void
+ */
void sspt_file_free(struct sspt_file *file)
{
struct hlist_head *head;
@@ -121,6 +134,13 @@ static struct sspt_page *sspt_find_page_or_new(struct sspt_file *file, unsigned
return page;
}
+/**
+ * @brief Get sspt_page from sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param page Page address
+ * @return Pointer to the sspt_page struct
+ */
struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long page)
{
unsigned long offset;
@@ -137,6 +157,15 @@ struct sspt_page *sspt_find_page_mapped(struct sspt_file *file, unsigned long pa
return sspt_find_page(file, offset);
}
+/**
+ * @brief Add instruction pointer to sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param offset File offset
+ * @param args Function arguments
+ * @param ret_type Return type
+ * @return Void
+ */
void sspt_file_add_ip(struct sspt_file *file, unsigned long offset,
const char *args, char ret_type)
{
@@ -148,6 +177,13 @@ void sspt_file_add_ip(struct sspt_file *file, unsigned long offset,
sspt_add_ip(page, ip);
}
+/**
+ * @brief Get sspt_page from sspt_file (look)
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param offset_addr File offset
+ * @return Pointer to the sspt_page struct
+ */
struct sspt_page *sspt_get_page(struct sspt_file *file, unsigned long offset_addr)
{
unsigned long offset = offset_addr & PAGE_MASK;
@@ -158,11 +194,25 @@ struct sspt_page *sspt_get_page(struct sspt_file *file, unsigned long offset_add
return page;
}
+/**
+ * @brief Put sspt_page (unlook)
+ *
+ * @param file Pointer to the sspt_page struct
+ * @return void
+ */
void sspt_put_page(struct sspt_page *page)
{
spin_unlock(&page->lock);
}
+/**
+ * @brief Check install sspt_file (legacy code, it is need remove)
+ *
+ * @param file Pointer to the sspt_file struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int sspt_file_check_install_pages(struct sspt_file *file)
{
int i, table_size;
@@ -184,6 +234,12 @@ int sspt_file_check_install_pages(struct sspt_file *file)
return 0;
}
+/**
+ * @brief Install sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @return Void
+ */
void sspt_file_install(struct sspt_file *file)
{
struct sspt_page *page = NULL;
@@ -208,6 +264,14 @@ void sspt_file_install(struct sspt_file *file)
}
}
+/**
+ * @brief Uninstall sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param task Pointer to the task_stract struct
+ * @param flag Action for probes
+ * @return Void
+ */
int sspt_file_uninstall(struct sspt_file *file, struct task_struct *task, enum US_FLAGS flag)
{
int i, err = 0;
@@ -235,6 +299,13 @@ int sspt_file_uninstall(struct sspt_file *file, struct task_struct *task, enum U
return err;
}
+/**
+ * @brief Set mapping for sspt_file
+ *
+ * @param file Pointer to the sspt_file struct
+ * @param vma Pointer to the vm_area_struct struct
+ * @return Void
+ */
void sspt_file_set_mapping(struct sspt_file *file, struct vm_area_struct *vma)
{
file->vm_start = vma->vm_start;
diff --git a/us_manager/sspt/sspt_file.h b/us_manager/sspt/sspt_file.h
index f4006826..ce55c38a 100644
--- a/us_manager/sspt/sspt_file.h
+++ b/us_manager/sspt/sspt_file.h
@@ -1,10 +1,11 @@
#ifndef __SSPT_FILE__
#define __SSPT_FILE__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/sspt_file.h
+/**
+ * @file us_manager/sspt/sspt_file.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -19,10 +20,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include "ip.h"
@@ -31,16 +30,20 @@
enum US_FLAGS;
struct vm_area_struct;
+/**
+ * @struct sspt_file
+ * @breaf Image of file for specified process
+ */
struct sspt_file {
- struct list_head list; // for proc_probes
- struct sspt_proc *proc;
- struct dentry *dentry;
- int loaded;
- unsigned long vm_start;
- unsigned long vm_end;
-
- unsigned long page_probes_hash_bits;
- struct hlist_head *page_probes_table; // for page_probes
+ struct list_head list; /**< For sspt_proc */
+ struct sspt_proc *proc; /**< Pointer to the proc (parent) */
+ struct dentry *dentry; /**< Dentry of file */
+ int loaded; /**< Flag of loading */
+ unsigned long vm_start; /**< VM start */
+ unsigned long vm_end; /**< VM end */
+
+ unsigned long page_probes_hash_bits; /**< Hash-table size */
+ struct hlist_head *page_probes_table; /**< Hash-table for pages */
};
diff --git a/us_manager/sspt/sspt_page.c b/us_manager/sspt/sspt_page.c
index 0c9128ed..0c70f26d 100644
--- a/us_manager/sspt/sspt_page.c
+++ b/us_manager/sspt/sspt_page.c
@@ -29,6 +29,12 @@
#include <linux/slab.h>
#include <linux/list.h>
+/**
+ * @brief Create sspt_page struct
+ *
+ * @param offset File ofset
+ * @return Pointer to the created sspt_page struct
+ */
struct sspt_page *sspt_page_create(unsigned long offset)
{
struct sspt_page *obj = kmalloc(sizeof(*obj), GFP_ATOMIC);
@@ -44,6 +50,12 @@ struct sspt_page *sspt_page_create(unsigned long offset)
return obj;
}
+/**
+ * @brief Remove sspt_page struct
+ *
+ * @param page remove object
+ * @return Void
+ */
void sspt_page_free(struct sspt_page *page)
{
struct us_ip *ip, *n;
@@ -72,6 +84,13 @@ static void sspt_list_del_ip(struct us_ip *ip)
list_del(&ip->list);
}
+/**
+ * @brief Add instruction pointer to sspt_page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @param ip Pointer to the us_ip struct
+ * @return Void
+ */
void sspt_add_ip(struct sspt_page *page, struct us_ip *ip)
{
ip->offset &= ~PAGE_MASK;
@@ -79,12 +98,26 @@ void sspt_add_ip(struct sspt_page *page, struct us_ip *ip)
sspt_list_add_ip(page, ip);
}
+/**
+ * @brief Del instruction pointer from sspt_page
+ *
+ * @param ip Pointer to the us_ip struct
+ * @return Void
+ */
void sspt_del_ip(struct us_ip *ip)
{
sspt_list_del_ip(ip);
free_ip(ip);
}
+/**
+ * @brief Check if probes are set on the page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @return
+ * - 0 - false
+ * - 1 - true
+ */
int sspt_page_is_installed(struct sspt_page *page)
{
int empty;
@@ -96,6 +129,13 @@ int sspt_page_is_installed(struct sspt_page *page)
return !empty;
}
+/**
+ * @brief Install probes on the page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @param file Pointer to the sspt_file struct
+ * @return Error code
+ */
int sspt_register_page(struct sspt_page *page, struct sspt_file *file)
{
int err = 0;
@@ -140,6 +180,14 @@ unlock:
return 0;
}
+/**
+ * @brief Uninstall probes on the page
+ *
+ * @param page Pointer to the sspt_page struct
+ * @param flag Action for probes
+ * @param task Pointer to the task_struct struct
+ * @return Error code
+ */
int sspt_unregister_page(struct sspt_page *page,
enum US_FLAGS flag,
struct task_struct *task)
diff --git a/us_manager/sspt/sspt_page.h b/us_manager/sspt/sspt_page.h
index 782f7fa0..b3a94fcc 100644
--- a/us_manager/sspt/sspt_page.h
+++ b/us_manager/sspt/sspt_page.h
@@ -1,10 +1,11 @@
#ifndef __SSPT_PAGE__
#define __SSPT_PAGE__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/sspt_page.h
+/**
+ * @file us_manager/sspt/sspt_page.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -19,10 +20,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include <linux/types.h>
@@ -33,14 +32,18 @@ struct sspt_file;
struct task_struct;
enum US_FLAGS;
+/**
+ * @struct sspt_page
+ * @breaf Image of page for specified process
+ */
struct sspt_page {
- struct list_head ip_list_inst;
- struct list_head ip_list_no_inst;
- unsigned long offset;
- spinlock_t lock;
+ struct list_head ip_list_inst; /**< For installed ip */
+ struct list_head ip_list_no_inst; /**< For don'tinstalled ip */
+ unsigned long offset; /**< File offset */
+ spinlock_t lock; /**< Lock page */
- struct sspt_file *file;
- struct hlist_node hlist; // for file_probes
+ struct sspt_file *file; /**< Ptr to the file(parent)=*/
+ struct hlist_node hlist; /**< For sspt_file */
};
struct sspt_page *sspt_page_create(unsigned long offset);
diff --git a/us_manager/sspt/sspt_proc.c b/us_manager/sspt/sspt_proc.c
index 48ac617c..0d136f2a 100644
--- a/us_manager/sspt/sspt_proc.c
+++ b/us_manager/sspt/sspt_proc.c
@@ -68,27 +68,54 @@
static LIST_HEAD(proc_probes_list);
static DEFINE_RWLOCK(sspt_proc_rwlock);
+/**
+ * @brief Global read lock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_read_lock(void)
{
read_lock(&sspt_proc_rwlock);
}
+/**
+ * @brief Global read unlock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_read_unlock(void)
{
read_unlock(&sspt_proc_rwlock);
}
+/**
+ * @brief Global write lock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_write_lock(void)
{
write_lock(&sspt_proc_rwlock);
}
+/**
+ * @brief Global write unlock for sspt_proc
+ *
+ * @return Void
+ */
void sspt_proc_write_unlock(void)
{
write_unlock(&sspt_proc_rwlock);
}
+/**
+ * @brief Create sspt_proc struct
+ *
+ * @param task Pointer to the task_struct struct
+ * @param priv Private data
+ * @return Pointer to the created sspt_proc struct
+ */
struct sspt_proc *sspt_proc_create(struct task_struct *task, void *priv)
{
struct sspt_proc *proc = kmalloc(sizeof(*proc), GFP_ATOMIC);
@@ -114,6 +141,13 @@ struct sspt_proc *sspt_proc_create(struct task_struct *task, void *priv)
return proc;
}
+/**
+ * @brief Remove sspt_proc struct
+ *
+ * @param proc remove object
+ * @return Void
+ */
+
/* called with sspt_proc_write_lock() */
void sspt_proc_free(struct sspt_proc *proc)
{
@@ -134,6 +168,12 @@ void sspt_proc_free(struct sspt_proc *proc)
kfree(proc);
}
+/**
+ * @brief Get sspt_proc by task
+ *
+ * @param task Pointer on the task_struct struct
+ * @return Pointer on the sspt_proc struct
+ */
struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task)
{
struct sspt_proc *proc, *tmp;
@@ -148,6 +188,13 @@ struct sspt_proc *sspt_proc_get_by_task(struct task_struct *task)
}
EXPORT_SYMBOL_GPL(sspt_proc_get_by_task);
+/**
+ * @brief Call func() on each proc (no lock)
+ *
+ * @param func Callback
+ * @param data Data for callback
+ * @return Void
+ */
void on_each_proc_no_lock(void (*func)(struct sspt_proc *, void *), void *data)
{
struct sspt_proc *proc, *tmp;
@@ -157,6 +204,13 @@ void on_each_proc_no_lock(void (*func)(struct sspt_proc *, void *), void *data)
}
}
+/**
+ * @brief Call func() on each proc
+ *
+ * @param func Callback
+ * @param data Data for callback
+ * @return Void
+ */
void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data)
{
sspt_proc_read_lock();
@@ -165,6 +219,13 @@ void on_each_proc(void (*func)(struct sspt_proc *, void *), void *data)
}
EXPORT_SYMBOL_GPL(on_each_proc);
+/**
+ * @brief Get sspt_proc by task or create sspt_proc
+ *
+ * @param task Pointer on the task_struct struct
+ * @param priv Private data
+ * @return Pointer on the sspt_proc struct
+ */
struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task,
void *priv)
{
@@ -176,6 +237,11 @@ struct sspt_proc *sspt_proc_get_by_task_or_new(struct task_struct *task,
return proc;
}
+/**
+ * @brief Free all sspt_proc
+ *
+ * @return Pointer on the sspt_proc struct
+ */
void sspt_proc_free_all(void)
{
struct sspt_proc *proc, *n;
@@ -190,6 +256,13 @@ static void sspt_proc_add_file(struct sspt_proc *proc, struct sspt_file *file)
file->proc = proc;
}
+/**
+ * @brief Get sspt_file from sspt_proc by dentry or new
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param dentry Dentry of file
+ * @return Pointer on the sspt_file struct
+ */
struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc,
struct dentry *dentry)
{
@@ -204,6 +277,13 @@ struct sspt_file *sspt_proc_find_file_or_new(struct sspt_proc *proc,
return file;
}
+/**
+ * @brief Get sspt_file from sspt_proc by dentry
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param dentry Dentry of file
+ * @return Pointer on the sspt_file struct
+ */
struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *dentry)
{
struct sspt_file *file;
@@ -217,6 +297,13 @@ struct sspt_file *sspt_proc_find_file(struct sspt_proc *proc, struct dentry *den
return NULL;
}
+/**
+ * @brief Install probes on the page to monitored process
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param page_addr Page address
+ * @return Void
+ */
void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr)
{
int lock, atomic;
@@ -248,6 +335,12 @@ void sspt_proc_install_page(struct sspt_proc *proc, unsigned long page_addr)
mm_read_unlock(mm, atomic, lock);
}
+/**
+ * @brief Install probes to monitored process
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @return Void
+ */
void sspt_proc_install(struct sspt_proc *proc)
{
int lock, atomic;
@@ -278,6 +371,14 @@ void sspt_proc_install(struct sspt_proc *proc)
mm_read_unlock(mm, atomic, lock);
}
+/**
+ * @brief Uninstall probes to monitored process
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param task Pointer on the task_struct struct
+ * @param flag Action for probes
+ * @return Error code
+ */
int sspt_proc_uninstall(struct sspt_proc *proc, struct task_struct *task, enum US_FLAGS flag)
{
int err = 0;
@@ -302,6 +403,15 @@ static int intersection(unsigned long start_a, unsigned long end_a,
start_a < end_b;
}
+/**
+ * @brief Get sspt_file list by region (remove sspt_file from sspt_proc list)
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param head[out] Pointer on the head list
+ * @param start Region start
+ * @param len Region length
+ * @return Error code
+ */
int sspt_proc_get_files_by_region(struct sspt_proc *proc,
struct list_head *head,
unsigned long start, size_t len)
@@ -320,6 +430,13 @@ int sspt_proc_get_files_by_region(struct sspt_proc *proc,
return ret;
}
+/**
+ * @brief Insert sspt_file to sspt_proc list
+ *
+ * @param proc Pointer on the sspt_proc struct
+ * @param head Pointer on the head list
+ * @return Void
+ */
void sspt_proc_insert_files(struct sspt_proc *proc, struct list_head *head)
{
list_splice(head, &proc->file_list);
diff --git a/us_manager/sspt/sspt_proc.h b/us_manager/sspt/sspt_proc.h
index 5fa7528d..49e0c9aa 100644
--- a/us_manager/sspt/sspt_proc.h
+++ b/us_manager/sspt/sspt_proc.h
@@ -1,10 +1,11 @@
#ifndef __SSPT_PROC__
#define __SSPT_PROC__
-/*
- * Dynamic Binary Instrumentation Module based on KProbes
- * modules/driver/sspt/sspt_proc.h
+/**
+ * @file us_manager/sspt/sspt_proc.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -19,10 +20,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
- *
*/
#include <linux/types.h>
@@ -31,20 +30,25 @@
struct slot_manager;
struct task_struct;
+/** Flags for sspt_*_uninstall() */
enum US_FLAGS {
- US_UNREGS_PROBE, /* probes remove and disarm */
- US_DISARM, /* probes disarm */
- US_UNINSTALL /* probes remove from list install */
+ US_UNREGS_PROBE, /**< probes remove and disarm */
+ US_DISARM, /**< probes disarm */
+ US_UNINSTALL /**< probes remove from list install */
};
+/**
+ * @struct sspt_proc
+ * @breaf Image of process for specified process
+ */
struct sspt_proc {
- struct list_head list;
- pid_t tgid;
- struct task_struct *task;
- struct slot_manager *sm;
- struct list_head file_list;
- unsigned first_install:1;
- struct sspt_feature *feature;
+ struct list_head list; /**< For global process list */
+ pid_t tgid; /**< Thread group ID */
+ struct task_struct *task; /**< Ptr to the task */
+ struct slot_manager *sm; /**< Ptr to the manager slot */
+ struct list_head file_list; /**< For sspt_file */
+ unsigned first_install:1; /**< Install flag */
+ struct sspt_feature *feature; /**< Ptr to the feature */
};
diff --git a/us_manager/us_manager.c b/us_manager/us_manager.c
index 8c5f3f22..08e9adc1 100644
--- a/us_manager/us_manager.c
+++ b/us_manager/us_manager.c
@@ -62,6 +62,11 @@ static int do_usm_start(void)
return 0;
}
+/**
+ * @brief Get instrumentation status
+ *
+ * @return Instrumentation status
+ */
enum status_type usm_get_status(void)
{
mutex_lock(&mutex_inst);
@@ -69,6 +74,12 @@ enum status_type usm_get_status(void)
}
EXPORT_SYMBOL_GPL(usm_get_status);
+/**
+ * @brief Put instrumentation status
+ *
+ * @param st Instrumentation status
+ * @return Void
+ */
void usm_put_status(enum status_type st)
{
status = st;
@@ -76,6 +87,11 @@ void usm_put_status(enum status_type st)
}
EXPORT_SYMBOL_GPL(usm_put_status);
+/**
+ * @brief Stop instrumentation
+ *
+ * @return Error code
+ */
int usm_stop(void)
{
int ret = 0;
@@ -95,6 +111,11 @@ put:
}
EXPORT_SYMBOL_GPL(usm_stop);
+/**
+ * @brief Start instrumentation
+ *
+ * @return Error code
+ */
int usm_start(void)
{
int ret = -EINVAL;
@@ -127,12 +148,23 @@ EXPORT_SYMBOL_GPL(usm_start);
*/
static enum quiet_type quiet = QT_ON;
+/**
+ * @brief Set quiet mode
+ *
+ * @param q Quiet mode
+ * @return Void
+ */
void set_quiet(enum quiet_type q)
{
quiet = q;
}
EXPORT_SYMBOL_GPL(set_quiet);
+/**
+ * @brief Get quiet mode
+ *
+ * @return Quiet mode
+ */
enum quiet_type get_quiet(void)
{
return quiet;
diff --git a/us_manager/us_manager.h b/us_manager/us_manager.h
index 4218234d..f1bf081c 100644
--- a/us_manager/us_manager.h
+++ b/us_manager/us_manager.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/us_manager.h
+/**
+ * @file us_manager/us_manager.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,24 +17,24 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/
#ifndef _US_MANAGER_H
#define _US_MANAGER_H
+/** Quiet mode */
enum quiet_type {
- QT_ON,
- QT_OFF
+ QT_ON, /**< Quiet mode - on */
+ QT_OFF /**< Quiet mode - off */
};
+/** Instrumentation status */
enum status_type {
- ST_OFF,
- ST_ON
+ ST_OFF, /**< Instrumentation status - off */
+ ST_ON /**< Instrumentation status - on */
};
void set_quiet(enum quiet_type q);
diff --git a/us_manager/us_slot_manager.c b/us_manager/us_slot_manager.c
index d600cea1..02aecfe7 100644
--- a/us_manager/us_slot_manager.c
+++ b/us_manager/us_slot_manager.c
@@ -66,6 +66,12 @@ static void sm_free_us(struct slot_manager *sm, void *ptr)
/* FIXME: implement the removal of memory for task */
}
+/**
+ * @brief Create slot_manager struct for US
+ *
+ * @param task Pointer to the task_struct struct
+ * @return Pointer to the created slot_manager struct
+ */
struct slot_manager *create_sm_us(struct task_struct *task)
{
struct slot_manager *sm = kmalloc(sizeof(*sm), GFP_ATOMIC);
@@ -78,6 +84,12 @@ struct slot_manager *create_sm_us(struct task_struct *task)
return sm;
}
+/**
+ * @brief Remove slot_manager struct for US
+ *
+ * @param sm remove object
+ * @return Void
+ */
void free_sm_us(struct slot_manager *sm)
{
if (sm == NULL)
diff --git a/us_manager/us_slot_manager.h b/us_manager/us_slot_manager.h
index 6dd42bc8..144d4a48 100644
--- a/us_manager/us_slot_manager.h
+++ b/us_manager/us_slot_manager.h
@@ -1,7 +1,8 @@
-/*
- * SWAP uprobe manager
- * modules/us_manager/us_slot_manager.h
+/**
+ * @file us_manager/us_slot_manager.h
+ * @author Vyacheslav Cherkashin <v.cherkashin@samsung.com>
*
+ * @section LICENSE
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,10 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
+ * @section COPYRIGHT
* Copyright (C) Samsung Electronics, 2013
- *
- * 2013 Vyacheslav Cherkashin: SWAP us_manager implement
- *
*/