diff options
| author | Rui Paulo <rpaulo@FreeBSD.org> | 2015-02-20 20:02:47 +0000 |
|---|---|---|
| committer | Rui Paulo <rpaulo@FreeBSD.org> | 2015-02-20 20:02:47 +0000 |
| commit | 7ea7c966673345f96526ebb718cd94e3ce5ee3a4 (patch) | |
| tree | 6ee506cefbdf2326d0cbcca569190eb6ec4d9b2f | |
| parent | 6837b52fcf3937c937d74b369ee15f489f164683 (diff) | |
Notes
| -rw-r--r-- | lib/libproc/proc_sym.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c index aa879ec128e1..ac61e2a55ff6 100644 --- a/lib/libproc/proc_sym.c +++ b/lib/libproc/proc_sym.c @@ -71,6 +71,21 @@ fail: strlcpy(buf, symbol, len); } +static int +find_dbg_obj(const char *path) +{ + int fd; + char dbg_path[PATH_MAX]; + + snprintf(dbg_path, sizeof(dbg_path), + "/usr/lib/debug/%s.debug", path); + fd = open(dbg_path, O_RDONLY); + if (fd > 0) + return (fd); + else + return (open(path, O_RDONLY)); +} + static void proc_rdl2prmap(rd_loadobj_t *rdl, prmap_t *map) { @@ -247,7 +262,7 @@ proc_addr2sym(struct proc_handle *p, uintptr_t addr, char *name, if ((map = proc_addr2map(p, addr)) == NULL) return (-1); - if ((fd = open(map->pr_mapname, O_RDONLY, 0)) < 0) { + if ((fd = find_dbg_obj(map->pr_mapname)) < 0) { DPRINTF("ERROR: open %s failed", map->pr_mapname); goto err0; } @@ -428,7 +443,7 @@ proc_name2sym(struct proc_handle *p, const char *object, const char *symbol, DPRINTFX("ERROR: couldn't find object %s", object); goto err0; } - if ((fd = open(map->pr_mapname, O_RDONLY, 0)) < 0) { + if ((fd = find_dbg_obj(map->pr_mapname)) < 0) { DPRINTF("ERROR: open %s failed", map->pr_mapname); goto err0; } @@ -525,7 +540,7 @@ proc_iter_symbyaddr(struct proc_handle *p, const char *object, int which, if ((map = proc_name2map(p, object)) == NULL) return (-1); - if ((fd = open(map->pr_mapname, O_RDONLY)) < 0) { + if ((fd = find_dbg_obj(map->pr_mapname)) < 0) { DPRINTF("ERROR: open %s failed", map->pr_mapname); goto err0; } |
