This commit is contained in:
zy
2023-11-16 14:07:26 +08:00
parent 29c0e81de5
commit 1e9c7be927
11 changed files with 22 additions and 14 deletions

View File

@@ -4,8 +4,8 @@ CFLAGS = -Wall
PROG = helloworld
HPTEST = hptest
UDIR = $(PWD)/user
MDIR := $(PWD)/kernel
UDIR = $(PWD)/source/uapi
MDIR := $(PWD)/source/module
KDIR := $(PWD)/linux-5.17.15 # 内核源码目录
TDIR := $(PWD)/testcase

View File

@@ -131,14 +131,7 @@ int init_module(void) {
printk(KERN_INFO "dev number: %d\n", dev_num);
printk(KERN_INFO "path: /dev/%s %d\n", DEVICE_NAME, dev_num);
fn_kallsyms_lookup_name_init(); // init kallsyms_lookup_name
LOOKUP_SYMS(stack_trace_save_tsk); // stack_trace_save_tsk
LOOKUP_SYMS(show_stack); // show_stack
LOOKUP_SYMS(idle_sched_class); // idle_sched_class
LOOKUP_SYMS(access_remote_vm); // access_remote_vm
LOOKUP_SYMS_NORET(get_task_type); // get_task_type
LOOKUP_SYMS_NORET(kernfs_name); // kernfs_name
monitor_init();
return 0;
}
@@ -154,4 +147,16 @@ void cleanup_module(void) {
unregister_chrdev_region(dev_num, 1);
}
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
// one more thing
int monitor_init(void){
fn_kallsyms_lookup_name_init(); // init kallsyms_lookup_name
LOOKUP_SYMS(stack_trace_save_tsk); // stack_trace_save_tsk
LOOKUP_SYMS(show_stack); // show_stack
LOOKUP_SYMS(idle_sched_class); // idle_sched_class
LOOKUP_SYMS(access_remote_vm); // access_remote_vm
LOOKUP_SYMS_NORET(get_task_type); // get_task_type
LOOKUP_SYMS_NORET(kernfs_name); // kernfs_name
}

View File

@@ -176,4 +176,7 @@ static void print_task_stack(void) {
unsigned char del_all_kwarg_by_pid(pid_t pid);
void clear_watch(pid_t pid);
void clear_all_watch(void);
void clear_all_watch(void);
// one more thing
int monitor_init(void);

View File

@@ -1,4 +1,4 @@
#include "../user/monitor_user.h"
#include "../source/uapi/monitor_user.h"
#include <stdio.h>
#include <unistd.h>
#include <string.h>

View File

@@ -1,4 +1,4 @@
#include "../user/monitor_user.h"
#include "../source/uapi/monitor_user.h"
#include <fcntl.h>
#include <stdio.h>
#include <sys/mman.h>