aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRui Paulo <rpaulo@FreeBSD.org>2015-02-13 03:18:29 +0000
committerRui Paulo <rpaulo@FreeBSD.org>2015-02-13 03:18:29 +0000
commiteda94c07de53d96a7453d9a33f37ee1a3f3b1803 (patch)
tree553a178d79a8c3a6b7defce082e2e5753f9b9c49 /lib
parente6c4672e82fcd7f5a88beef3f344965c4648445a (diff)
downloadsrc-eda94c07de53d96a7453d9a33f37ee1a3f3b1803.tar.gz
src-eda94c07de53d96a7453d9a33f37ee1a3f3b1803.zip
Teach libproc how to find debugging symbols in /usr/lib/debug.
MFC after: 1 week
Notes
Notes: svn path=/head/; revision=278658
Diffstat (limited to 'lib')
-rw-r--r--lib/libproc/proc_sym.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c
index d4f82629fb7b..5c5ac558bf64 100644
--- a/lib/libproc/proc_sym.c
+++ b/lib/libproc/proc_sym.c
@@ -82,6 +82,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)
{
@@ -295,7 +310,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;
}
@@ -443,7 +458,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;
}
@@ -539,7 +554,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;
}