proc add stack_capture_mode

This commit is contained in:
zy
2023-12-19 22:19:57 -05:00
parent b1c831d63d
commit 46a03f0357
2 changed files with 19 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ const char* proc_dir = "variable_monitor";
int def_interval_ns = DEFAULT_INTERVAL_NS;
int dump_reset_sec = DEFAULT_DUMP_RESET_SEC;
int sample_all = DEFAULT_SAMPLE_ALL;
int stack_capture_mode = STACK_CAPTURE_AGGREGATE;
static ssize_t read_proc(struct file *file, char __user *buf, size_t count,
loff_t *offset, int *var) {
@@ -64,6 +65,15 @@ static ssize_t write_proc_sample_all(struct file *file,
loff_t *offset) {
return write_proc(file, buf, count, offset, &sample_all);
}
static ssize_t read_stack_capture_mode(struct file *file, char __user *buf,
size_t count, loff_t *offset) {
return read_proc(file, buf, count, offset, &stack_capture_mode);
}
static ssize_t write_stack_capture_mode(struct file *file,
const char __user *buf, size_t count,
loff_t *offset) {
return write_proc(file, buf, count, offset, &stack_capture_mode);
}
static const struct proc_ops proc_def_interval_ns_ops = {
.proc_read = read_proc_def_interval_ns,
@@ -80,6 +90,11 @@ static const struct proc_ops proc_sample_all_ops = {
.proc_write = write_proc_sample_all,
};
static const struct proc_ops stack_capture_mode_ops = {
.proc_read = read_stack_capture_mode,
.proc_write = write_stack_capture_mode,
};
int monitor_proc_init(void) {
struct proc_dir_entry *dir;
@@ -92,6 +107,7 @@ int monitor_proc_init(void) {
proc_create("def_interval_ns", 0666, dir, &proc_def_interval_ns_ops);
proc_create("dump_reset_sec", 0666, dir, &proc_dump_reset_sec_ops);
proc_create("sample_all", 0666, dir, &proc_sample_all_ops);
proc_create("stack_capture_mode", 0666, dir, &stack_capture_mode_ops);
return 0;
}

View File

@@ -4,10 +4,13 @@
#define DEFAULT_INTERVAL_NS 10000 // 10us
#define DEFAULT_DUMP_RESET_SEC 10 // 60s
#define DEFAULT_SAMPLE_ALL 0
#define STACK_CAPTURE_IMMEDIATE 0
#define STACK_CAPTURE_AGGREGATE 1
extern int def_interval_ns;
extern int dump_reset_sec;
extern int sample_all;
extern int stack_capture_mode;
int monitor_proc_init(void);
int monitor_proc_exit(void);