From d2f4d7286629da6e9f1b844beefb141a4d3ef2c3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 10 Dec 2008 20:39:45 +0100 Subject: PR6866: First pass at translating addresses to symbol names through vma. --- testsuite/systemtap.context/usymbols.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 testsuite/systemtap.context/usymbols.c (limited to 'testsuite/systemtap.context/usymbols.c') diff --git a/testsuite/systemtap.context/usymbols.c b/testsuite/systemtap.context/usymbols.c new file mode 100644 index 00000000..f8ee05b5 --- /dev/null +++ b/testsuite/systemtap.context/usymbols.c @@ -0,0 +1,41 @@ +/* usymbol test case + * Copyright (C) 2008, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + * + * Uses signal to tranfer user space addresses into the kernel where a + * probe on sigaction will extract them and produce the symbols. To + * poke into the executable we get the sa_handler, to poke into glibc + * we get the sa_restorer fields in the stap script. + * + * XXX - Seems sa_restorer isn't set on all architectures. should use + * our own shared library and set signal handler from there. Also + * need to handle @plt symbols (setting a handler in the main + * executable that is in a shared library will have the @plt address, + * not the address inside the shared library). + */ + +#include +typedef void (*sighandler_t)(int); + +void +handler (int signum) +{ + /* dummy handler, just used for the address... */ +} + +sighandler_t +libc_handler (void *func) +{ + return (sighandler_t) func; +} + +int +main (int argc, char *argv[], char *envp[]) +{ + // Use SIGFPE since we never expect that to be triggered. + signal(SIGFPE, handler); +} -- cgit From 6e44f060ffb5fff8d3987024d8facfb7997a3b25 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 15 Dec 2008 18:20:04 +0100 Subject: Compile and use helper usymbols_lib.c library for usymbols.exp test. --- testsuite/systemtap.context/usymbols.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'testsuite/systemtap.context/usymbols.c') diff --git a/testsuite/systemtap.context/usymbols.c b/testsuite/systemtap.context/usymbols.c index f8ee05b5..7c590724 100644 --- a/testsuite/systemtap.context/usymbols.c +++ b/testsuite/systemtap.context/usymbols.c @@ -8,34 +8,32 @@ * * Uses signal to tranfer user space addresses into the kernel where a * probe on sigaction will extract them and produce the symbols. To - * poke into the executable we get the sa_handler, to poke into glibc - * we get the sa_restorer fields in the stap script. + * poke into the executable we get the sa_handler from the main executable, + * and then the library through calling signal. * - * XXX - Seems sa_restorer isn't set on all architectures. should use - * our own shared library and set signal handler from there. Also - * need to handle @plt symbols (setting a handler in the main - * executable that is in a shared library will have the @plt address, - * not the address inside the shared library). + * FIXME. We call into the library to get the right symbol. If we + * register the handler from the main executable. We need to handle + * @plt symbols (setting a handler in the main executable that is in a + * shared library will have the @plt address, not the address inside + * the shared library). */ #include typedef void (*sighandler_t)(int); +// function from our library +int lib_main (void); + void -handler (int signum) +main_handler (int signum) { /* dummy handler, just used for the address... */ } -sighandler_t -libc_handler (void *func) -{ - return (sighandler_t) func; -} - int main (int argc, char *argv[], char *envp[]) { // Use SIGFPE since we never expect that to be triggered. - signal(SIGFPE, handler); + signal(SIGFPE, main_handler); + lib_main(); } -- cgit