diff options
Diffstat (limited to 'runtime/transport')
-rw-r--r-- | runtime/transport/control.c | 7 | ||||
-rw-r--r-- | runtime/transport/symbols.c | 63 | ||||
-rw-r--r-- | runtime/transport/transport.c | 3 | ||||
-rw-r--r-- | runtime/transport/transport_msgs.h | 11 |
4 files changed, 61 insertions, 23 deletions
diff --git a/runtime/transport/control.c b/runtime/transport/control.c index 9319b9ca..b366ccef 100644 --- a/runtime/transport/control.c +++ b/runtime/transport/control.c @@ -56,9 +56,10 @@ static ssize_t _stp_ctl_write_cmd(struct file *file, const char __user *buf, siz #else return -1; #endif + case STP_RELOCATION: + _stp_do_relocation (buf, count); + case STP_READY: - /* request symbolic information */ - /* _stp_ask_for_symbols(); */ break; default: @@ -66,7 +67,7 @@ static ssize_t _stp_ctl_write_cmd(struct file *file, const char __user *buf, siz return -EINVAL; } - return count; + return count; /* Pretend that we absorbed the entire message. */ } struct _stp_buffer { diff --git a/runtime/transport/symbols.c b/runtime/transport/symbols.c index 9299fc67..cc0a1ce5 100644 --- a/runtime/transport/symbols.c +++ b/runtime/transport/symbols.c @@ -196,31 +196,54 @@ static int _stp_init_kernel_symbols(void) _stp_num_modules = 1; /* Note: this mapping is used by kernel/_stext pseudo-relocations. */ - #ifdef __powerpc__ - _stp_modules[0]->text = _stp_kallsyms_lookup_name(".__start"); - #else - _stp_modules[0]->text = _stp_kallsyms_lookup_name("_stext"); - #endif - if (_stp_modules[0]->text == 0) { - _dbug("Lookup of _stext failed. Exiting.\n"); - return -1; - } - - _stp_modules[0]->data = _stp_kallsyms_lookup_name("_etext"); - if (_stp_modules[0]->data == 0) { - _dbug("Lookup of _etext failed. Exiting.\n"); - return -1; - } + _stp_modules[0]->text = 0; /* This should be set by a STP_RELOCATE message. */ + _stp_modules[0]->data = 0; /* XXX */ + _stp_modules[0]->text_size = 0; /* XXX */ - _stp_modules[0]->text_size = _stp_modules[0]->data - _stp_modules[0]->text; + _stp_kretprobe_trampoline = 0; /* XXX */ _stp_modules_by_addr[0] = _stp_modules[0]; - - _stp_kretprobe_trampoline = _stp_kallsyms_lookup_name("kretprobe_trampoline"); - /* Lookup failure is not fatal */ + + printk (KERN_INFO "stap kernel data: symbols[%u]=%p\n", + _stp_num_kernel_symbols, _stp_kernel_symbols); return 0; } + +static void _stp_do_relocation(const char __user *buf, size_t count) +{ + struct _stp_msg_relocation msg; + if (sizeof(msg) != count) + { + errk ("STP_RELOCATE message size mismatch (%u vs %u)\n", sizeof(msg), count); + return; + } + + if (unlikely(copy_from_user (& msg, buf, count))) + return; + + dbug_sym (1, "STP_RELOCATE (%s %s %lx)\n", msg.module, msg.reloc, + (unsigned long) msg.address); + + if (!strcmp (msg.module, "kernel") && + !strcmp (msg.reloc, "_stext")) + + { + unsigned i; + + _stp_modules[0]->text = (unsigned long) msg.address; + + /* Now, relocate all the elements in the kernel symbol table. + We should at that point arrive at a strict subset of the + /proc/kallsyms table. */ + + for (i=0; i<_stp_modules[0]->num_symbols; i++) + _stp_modules[0]->symbols[i].addr += msg.address; + } +} + + +#if 0 static void _stp_do_unwind_data(const char __user *buf, size_t count) { u32 unwind_len; @@ -302,6 +325,8 @@ static void _stp_do_unwind_data(const char __user *buf, size_t count) done: write_unlock(&m->lock); } +#endif /* do_unwind_data; not used */ + static int _stp_compare_addr(const void *p1, const void *p2) { diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index a4e4e652..d149dd15 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -267,10 +267,11 @@ int _stp_transport_init(void) if (_stp_init_kernel_symbols() < 0) goto err4; + /* dbug_trans(1, "calling init_modules\n"); if (_stp_init_modules() < 0) goto err4; - + */ return 0; err4: diff --git a/runtime/transport/transport_msgs.h b/runtime/transport/transport_msgs.h index 27476e76..493c7105 100644 --- a/runtime/transport/transport_msgs.h +++ b/runtime/transport/transport_msgs.h @@ -10,6 +10,7 @@ */ #define STP_MODULE_NAME_LEN 64 +#define STP_SYMBOL_NAME_LEN 64 struct _stp_trace { uint32_t sequence; /* event number */ @@ -34,6 +35,7 @@ enum STP_SUBBUFS_CONSUMED, STP_REALTIME_DATA, #endif + STP_RELOCATION, STP_MAX_CMD }; @@ -53,6 +55,7 @@ static const char *_stp_command_name[] = { "STP_SUBBUFS_CONSUMED", "STP_REALTIME_DATA", #endif + "STP_RELOCATION", }; #endif /* DEBUG_TRANS */ @@ -97,3 +100,11 @@ struct _stp_consumed_info uint32_t consumed; }; #endif + +/* Unwind data. stapio->module */ +struct _stp_msg_relocation +{ + char module[STP_MODULE_NAME_LEN]; + char reloc[STP_SYMBOL_NAME_LEN]; + uint64_t address; +}; |