| 1 | /* |
| 2 | * Copyright (C) 2013 Paul Woegerer <paul_woegerer@mentor.com> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #define _GNU_SOURCE |
| 20 | #include <dlfcn.h> |
| 21 | #include <link.h> |
| 22 | |
| 23 | #include <sys/types.h> |
| 24 | #include <sys/stat.h> |
| 25 | #include <sys/stat.h> |
| 26 | #include <unistd.h> |
| 27 | #include <limits.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <errno.h> |
| 30 | #include <stdint.h> |
| 31 | #include <stddef.h> |
| 32 | #include <stdio.h> |
| 33 | #include "usterr.h" |
| 34 | |
| 35 | #define TRACEPOINT_DEFINE |
| 36 | #include "ust_baddr.h" |
| 37 | |
| 38 | int |
| 39 | lttng_ust_push_baddr(void *so_base, const char *so_name) |
| 40 | { |
| 41 | char resolved_path[PATH_MAX]; |
| 42 | struct stat sostat; |
| 43 | |
| 44 | if (!realpath(so_name, resolved_path)) { |
| 45 | ERR("could not resolve path '%s'", so_name); |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | if (stat(resolved_path, &sostat)) { |
| 50 | ERR("could not access file status for %s", resolved_path); |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | tracepoint(ust_baddr, push, |
| 55 | so_base, resolved_path, sostat.st_size, sostat.st_mtime); |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | int |
| 60 | lttng_ust_pop_baddr(void *so_base) |
| 61 | { |
| 62 | tracepoint(ust_baddr, pop, so_base); |
| 63 | return 0; |
| 64 | } |