[OE-core] [PATCH 1/3] base/bbclass: use target path as compile dir in debugging info

Hongxu Jia hongxu.jia at windriver.com
Thu Jan 28 14:47:43 UTC 2016


In debugging information, it uses target paths rather than
build ones as compile dir.
...
 -fdebug-prefix-map=old=new
   When compiling files in directory old, record debugging
   information describing them as in new instead.
...

Compile without this fix:
objdump -g git/test.o
...
 The Directory Table (offset 0x1b):
|  1     /buildarea/raid0/hjia/build-20160119-yocto-buildpath/tmp/sysroots/x86_64-linux/usr/lib/
i686-pokymllib32-linux.lib32-gcc-cross-initial-i686/gcc/i686-pokymllib32-linux/5.3.0/include
|  2     /buildarea/raid0/hjia/build-20160119-yocto-buildpath/tmp/sysroots/lib32-qemux86-64/usr/include/bits
|  3     /buildarea/raid0/hjia/build-20160119-yocto-buildpath/tmp/sysroots/lib32-qemux86-64/usr/include
...

Compile with this fix:
objdump -g git/test.o
...
 The Directory Table (offset 0x1b):
|  1     /usr/lib/i686-pokymllib32-linux.lib32-gcc-cross-initial-i686/gcc/i686-pokymllib32-linux/
5.3.0/include
|  2     /usr/include/bits
|  3     /usr/include
...

[YOCTO #7058]

Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
---
 meta/classes/base.bbclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 5fc9271..3a43661 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -85,6 +85,24 @@ FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${
 # in the context of the location its used (:=)
 THISDIR = "${@os.path.dirname(d.getVar('FILE', True))}"
 
+def debug_prefix_map(d):
+    opts = ""
+    if "-g" in (d.getVar("SELECTED_OPTIMIZATION", True) or "").split():
+        targetsrc = "/usr/src/%s" % d.getVar("BPN", True)
+        for var in ["S", "B"]:
+            buildsrc = d.getVar(var, True)
+            opt = " -fdebug-prefix-map=%s=%s" % (buildsrc, targetsrc)
+            if opt not in opts:
+                opts += opt
+
+        for var in ["STAGING_DIR_NATIVE", "STAGING_DIR_HOST"]:
+            buildinc = d.getVar(var, True)
+            opts += " -fdebug-prefix-map=%s=" % (buildinc)
+
+    return opts
+
+TARGET_CFLAGS += "${@debug_prefix_map(d)}"
+
 def extra_path_elements(d):
     path = ""
     elements = (d.getVar('EXTRANATIVEPATH', True) or "").split()
-- 
1.9.1




More information about the Openembedded-core mailing list