Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Feb 2015 20:02:47 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r279082 - stable/10/lib/libproc
Message-ID:  <201502202002.t1KK2lVq058040@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Fri Feb 20 20:02:47 2015
New Revision: 279082
URL: https://svnweb.freebsd.org/changeset/base/279082

Log:
  MFC r278658:
  
    Teach libproc how to find debugging symbols in /usr/lib/debug.

Modified:
  stable/10/lib/libproc/proc_sym.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libproc/proc_sym.c
==============================================================================
--- stable/10/lib/libproc/proc_sym.c	Fri Feb 20 19:48:24 2015	(r279081)
+++ stable/10/lib/libproc/proc_sym.c	Fri Feb 20 20:02:47 2015	(r279082)
@@ -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, uin
 
 	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, con
 		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 *
 
 	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;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502202002.t1KK2lVq058040>