-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikael Starvik
authored and
Linus Torvalds
committed
Jul 27, 2005
1 parent
50bc73e
commit 3d4eb6f
Showing
4 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 59c61138a556cf89692e0d5bd2c9de5df54b824f | ||
refs/heads/master: 21783c9746619a782c21be606f6498bbd4d4615e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <linux/init.h> | ||
#include <linux/errno.h> | ||
#include <linux/kernel.h> | ||
#include <linux/proc_fs.h> | ||
#include <linux/types.h> | ||
#include <asm/ptrace.h> | ||
#include <asm/uaccess.h> | ||
|
||
#define SAMPLE_BUFFER_SIZE 8192 | ||
|
||
static char* sample_buffer; | ||
static char* sample_buffer_pos; | ||
static int prof_running = 0; | ||
|
||
void | ||
cris_profile_sample(struct pt_regs* regs) | ||
{ | ||
if (!prof_running) | ||
return; | ||
if (user_mode(regs)) | ||
*(unsigned int*)sample_buffer_pos = current->pid; | ||
else | ||
*(unsigned int*)sample_buffer_pos = 0; | ||
*(unsigned int*)(sample_buffer_pos + 4) = instruction_pointer(regs); | ||
sample_buffer_pos += 8; | ||
if (sample_buffer_pos == sample_buffer + SAMPLE_BUFFER_SIZE) | ||
sample_buffer_pos = sample_buffer; | ||
} | ||
|
||
static ssize_t | ||
read_cris_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos) | ||
{ | ||
unsigned long p = *ppos; | ||
if (p > SAMPLE_BUFFER_SIZE) | ||
return 0; | ||
if (p + count > SAMPLE_BUFFER_SIZE) | ||
count = SAMPLE_BUFFER_SIZE - p; | ||
if (copy_to_user(buf, sample_buffer + p,count)) | ||
return -EFAULT; | ||
memset(sample_buffer + p, 0, count); | ||
*ppos += count; | ||
return count; | ||
} | ||
|
||
static ssize_t | ||
write_cris_profile(struct file *file, const char __user *buf, | ||
size_t count, loff_t *ppos) | ||
{ | ||
sample_buffer_pos = sample_buffer; | ||
memset(sample_buffer, 0, SAMPLE_BUFFER_SIZE); | ||
} | ||
|
||
static struct file_operations cris_proc_profile_operations = { | ||
.read = read_cris_profile, | ||
.write = write_cris_profile, | ||
}; | ||
|
||
static int | ||
__init init_cris_profile(void) | ||
{ | ||
struct proc_dir_entry *entry; | ||
sample_buffer = (char*)kmalloc(SAMPLE_BUFFER_SIZE, GFP_KERNEL); | ||
sample_buffer_pos = sample_buffer; | ||
entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL); | ||
if (entry) { | ||
entry->proc_fops = &cris_proc_profile_operations; | ||
entry->size = SAMPLE_BUFFER_SIZE; | ||
} | ||
prof_running = 1; | ||
return 0; | ||
} | ||
|
||
__initcall(init_cris_profile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ | |
#define PTRACE_SETREGS 13 | ||
#endif | ||
|
||
#define profile_pc(regs) instruction_pointer(regs) | ||
|
||
#endif /* _CRIS_PTRACE_H */ |