diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2016-03-21 04:46:20 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-28 15:54:52 +0100 |
commit | ecb56a6ae0c870af680da03db9d39703b525fc98 (patch) | |
tree | 93e12659de4b725fad0f36d8de27a72f249cdc60 /meta | |
parent | a797abe08bfe4144e120c984d1718c2cc3d87c0a (diff) | |
download | openembedded-core-contrib-ecb56a6ae0c870af680da03db9d39703b525fc98.tar.gz |
conf/bitbake.conf package.bbclass: fix dbg package not contain sources while -fdebug-prefix-map used
Tweak DEBUG_FLAGS to use "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}"
as source target path in DWARF. While use gdb to debug binary, it could
work with sources in dbg package.
While -fdebug-prefix-map is used for compiling, we do not need invoking
debugedit to edit DWARF at do_package time, but list where sources files
are.
The copydebugsources uses the list to copy sources to dbg package. It
works whether -fdebug-prefix-map used or not.
[YOCTO #9305]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/package.bbclass | 24 | ||||
-rw-r--r-- | meta/conf/bitbake.conf | 3 |
2 files changed, 21 insertions, 6 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 5a842556662..bdbe96d4cba 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass @@ -300,6 +300,15 @@ def get_conffiles(pkg, d): os.chdir(cwd) return conf_list +def checkbuildpath(file, d): + tmpdir = d.getVar('TMPDIR', True) + with open(file) as f: + file_content = f.read() + if tmpdir in file_content: + return True + + return False + def splitdebuginfo(file, debugfile, debugsrcdir, sourcefile, d): # Function to split a single file into two components, one is the stripped # target system binary, the other contains any debugging information. The @@ -312,8 +321,6 @@ def splitdebuginfo(file, debugfile, debugsrcdir, sourcefile, d): dvar = d.getVar('PKGD', True) objcopy = d.getVar("OBJCOPY", True) debugedit = d.expand("${STAGING_LIBDIR_NATIVE}/rpm/bin/debugedit") - workdir = d.getVar("WORKDIR", True) - workparentdir = d.getVar("DEBUGSRC_OVERRIDE_PATH", True) or os.path.dirname(os.path.dirname(workdir)) # We ignore kernel modules, we don't generate debug info files. if file.find("/lib/modules/") != -1 and file.endswith(".ko"): @@ -327,7 +334,7 @@ def splitdebuginfo(file, debugfile, debugsrcdir, sourcefile, d): # We need to extract the debug src information here... if debugsrcdir: - cmd = "'%s' -b '%s' -d '%s' -i -l '%s' '%s'" % (debugedit, workparentdir, debugsrcdir, sourcefile, file) + cmd = "'%s' -i -l '%s' '%s'" % (debugedit, sourcefile, file) (retval, output) = oe.utils.getstatusoutput(cmd) if retval: bb.fatal("debugedit failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else "")) @@ -366,6 +373,13 @@ def copydebugsources(debugsrcdir, d): workparentdir = os.path.dirname(os.path.dirname(workdir)) workbasedir = os.path.basename(os.path.dirname(workdir)) + "/" + os.path.basename(workdir) + # If build path exists in sourcefile, it means toolchain did not use + # -fdebug-prefix-map to compile + if checkbuildpath(sourcefile, d): + localsrc_prefix = workparentdir + "/" + else: + localsrc_prefix = "/usr/src/debug/" + nosuchdir = [] basepath = dvar for p in debugsrcdir.split("/"): @@ -379,9 +393,11 @@ def copydebugsources(debugsrcdir, d): # We need to ignore files that are not actually ours # we do this by only paying attention to items from this package processdebugsrc += "fgrep -zw '%s' | " + # Remove prefix in the source paths + processdebugsrc += "sed 's#%s##g' | " processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" - cmd = processdebugsrc % (sourcefile, workbasedir, workparentdir, dvar, debugsrcdir) + cmd = processdebugsrc % (sourcefile, workbasedir, localsrc_prefix, workparentdir, dvar, debugsrcdir) (retval, output) = oe.utils.getstatusoutput(cmd) # Can "fail" if internal headers/transient sources are attempted #if retval: diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index d4fb5f35713..b873b4150d0 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -550,8 +550,7 @@ EXTRA_OEMAKE_prepend_task-install = "${PARALLEL_MAKEINST} " # Optimization flags. ################################################################## DEBUG_FLAGS ?= "-g -feliminate-unused-debug-types \ - -fdebug-prefix-map=${B}=/usr/src/${BPN} \ - -fdebug-prefix-map=${S}=/usr/src/${BPN} \ + -fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ -fdebug-prefix-map=${STAGING_DIR_HOST}= \ " |