| 1 |
#ifndef TASK_FINDER_STUBS_C |
| 2 |
#define TASK_FINDER_STUBS_C |
| 3 |
|
| 4 |
/* Stubs of last resort for when utrace type functionality is not |
| 5 |
available. Nothing should actually work, but things compile |
| 6 |
properly, and silently return dummy data or noisily fail as |
| 7 |
appropriate. */ |
| 8 |
|
| 9 |
static void stap_task_finder_unavailable(void) { |
| 10 |
_stp_error("process-tracking is not available in this kernel" |
| 11 |
" [man error::process-tracking]"); |
| 12 |
} |
| 13 |
|
| 14 |
struct stap_task_finder_target; |
| 15 |
|
| 16 |
typedef int (*stap_task_finder_callback)(struct stap_task_finder_target *tgt, |
| 17 |
struct task_struct *tsk, |
| 18 |
int register_p, |
| 19 |
int process_p); |
| 20 |
|
| 21 |
typedef int |
| 22 |
(*stap_task_finder_mmap_callback)(struct stap_task_finder_target *tgt, |
| 23 |
struct task_struct *tsk, |
| 24 |
char *path, |
| 25 |
struct dentry *dentry, |
| 26 |
unsigned long addr, |
| 27 |
unsigned long length, |
| 28 |
unsigned long offset, |
| 29 |
unsigned long vm_flags); |
| 30 |
typedef int |
| 31 |
(*stap_task_finder_munmap_callback)(struct stap_task_finder_target *tgt, |
| 32 |
struct task_struct *tsk, |
| 33 |
unsigned long addr, |
| 34 |
unsigned long length); |
| 35 |
|
| 36 |
typedef int |
| 37 |
(*stap_task_finder_mprotect_callback)(struct stap_task_finder_target *tgt, |
| 38 |
struct task_struct *tsk, |
| 39 |
unsigned long addr, |
| 40 |
unsigned long length, |
| 41 |
int prot); |
| 42 |
|
| 43 |
struct stap_task_finder_target { |
| 44 |
/* private: */ |
| 45 |
struct list_head list; /* __stp_task_finder_list linkage */ |
| 46 |
struct list_head callback_list_head; |
| 47 |
struct list_head callback_list; |
| 48 |
// struct utrace_engine_ops ops; |
| 49 |
size_t pathlen; |
| 50 |
unsigned engine_attached:1; |
| 51 |
unsigned mmap_events:1; |
| 52 |
unsigned munmap_events:1; |
| 53 |
unsigned mprotect_events:1; |
| 54 |
|
| 55 |
/* public: */ |
| 56 |
pid_t pid; |
| 57 |
const char *procname; |
| 58 |
const char *purpose; |
| 59 |
stap_task_finder_callback callback; |
| 60 |
stap_task_finder_mmap_callback mmap_callback; |
| 61 |
stap_task_finder_munmap_callback munmap_callback; |
| 62 |
stap_task_finder_mprotect_callback mprotect_callback; |
| 63 |
}; |
| 64 |
|
| 65 |
static int |
| 66 |
stap_register_task_finder_target(struct stap_task_finder_target *new_tgt) |
| 67 |
{ |
| 68 |
/* do not actually register anything -- callbacks will be ignored */ |
| 69 |
_stp_warn("cannot track target in process '%s'", new_tgt->procname); |
| 70 |
return 0; |
| 71 |
} |
| 72 |
|
| 73 |
static int |
| 74 |
stap_start_task_finder(void) |
| 75 |
{ |
| 76 |
_stp_warn("process-tracking is not available in this kernel" |
| 77 |
" [man error::process-tracking]"); |
| 78 |
|
| 79 |
return 0; |
| 80 |
} |
| 81 |
|
| 82 |
static void |
| 83 |
stap_task_finder_post_init(void) |
| 84 |
{ |
| 85 |
; |
| 86 |
} |
| 87 |
|
| 88 |
static void |
| 89 |
stap_stop_task_finder(void) |
| 90 |
{ |
| 91 |
; |
| 92 |
} |
| 93 |
|
| 94 |
#endif /* TASK_FINDER_STUBS_C */ |