Use ANDROID_TOOLCHAIN and ANDROID_TOOLCHAIN_2ND_ARCH in 'stack'.
This fixes the bug where we can't (currently) find the toolchain for arm because it's at a different GCC version (4.8) from arm64 (4.9). Change-Id: I22351af55298255f3ac4adfcae7e20080712fba4
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
The information can include symbol names, offsets, and source locations.
|
The information can include symbol names, offsets, and source locations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import glob
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -43,69 +44,45 @@ SYMBOLS_DIR = FindSymbolsDir()
|
|||||||
|
|
||||||
ARCH = "arm"
|
ARCH = "arm"
|
||||||
|
|
||||||
TOOLCHAIN_INFO = None
|
TOOLCHAIN = None
|
||||||
|
|
||||||
def Uname():
|
def ToolPath(tool, toolchain=None):
|
||||||
"""'uname' for constructing prebuilt/<...> and out/host/<...> paths."""
|
"""Return a fully-qualified path to the specified tool"""
|
||||||
uname = os.uname()[0]
|
if not toolchain:
|
||||||
if uname == "Darwin":
|
toolchain = FindToolchain()
|
||||||
proc = os.uname()[-1]
|
return glob.glob(os.path.join(toolchain, "*-" + tool))[0]
|
||||||
if proc == "i386" or proc == "x86_64":
|
|
||||||
return "darwin-x86"
|
|
||||||
return "darwin-ppc"
|
|
||||||
if uname == "Linux":
|
|
||||||
return "linux-x86"
|
|
||||||
return uname
|
|
||||||
|
|
||||||
def ToolPath(tool, toolchain_info=None):
|
|
||||||
"""Return a full qualified path to the specified tool"""
|
|
||||||
if not toolchain_info:
|
|
||||||
toolchain_info = FindToolchain()
|
|
||||||
(label, platform, target) = toolchain_info
|
|
||||||
return os.path.join(ANDROID_BUILD_TOP, "prebuilts/gcc", Uname(), platform, label, "bin",
|
|
||||||
target + "-" + tool)
|
|
||||||
|
|
||||||
def FindToolchain():
|
def FindToolchain():
|
||||||
"""Look for the latest available toolchain
|
"""Returns the toolchain matching ARCH. Assumes that you're lunched
|
||||||
|
such that the necessary toolchain is either your primary or secondary.
|
||||||
|
TODO: we could make this 'just work' for most users by just globbing the
|
||||||
|
newest toolchains for every architecture out of prebuilts/, but other
|
||||||
|
parts of this tool assume you're lunched correctly anyway."""
|
||||||
|
global TOOLCHAIN
|
||||||
|
if TOOLCHAIN is not None:
|
||||||
|
return TOOLCHAIN
|
||||||
|
|
||||||
Args:
|
# We say "arm64", GCC says "aarch64".
|
||||||
None
|
gcc_arch = ARCH
|
||||||
|
if gcc_arch == "arm64":
|
||||||
|
gcc_arch = "aarch64"
|
||||||
|
|
||||||
Returns:
|
tc1 = os.environ["ANDROID_TOOLCHAIN"]
|
||||||
A pair of strings containing toolchain label and target prefix.
|
tc2 = os.environ["ANDROID_TOOLCHAIN_2ND_ARCH"]
|
||||||
"""
|
|
||||||
global TOOLCHAIN_INFO
|
|
||||||
if TOOLCHAIN_INFO is not None:
|
|
||||||
return TOOLCHAIN_INFO
|
|
||||||
|
|
||||||
# TODO: TARGET_GCC_VERSION is the version for the primary architecture.
|
if (gcc_arch + "/" + gcc_arch + "-") in tc1:
|
||||||
gcc_version = os.environ["TARGET_GCC_VERSION"]
|
toolchain = tc1
|
||||||
|
elif (gcc_arch + "/" + gcc_arch + "-") in tc2:
|
||||||
## Known toolchains, newer ones in the front.
|
toolchain = tc2
|
||||||
if ARCH == "arm":
|
|
||||||
known_toolchains = [
|
|
||||||
("arm-linux-androideabi-" + gcc_version, "arm", "arm-linux-androideabi"),
|
|
||||||
]
|
|
||||||
elif ARCH == "arm64":
|
|
||||||
known_toolchains = [
|
|
||||||
("aarch64-linux-android-" + gcc_version, "aarch64", "aarch64-linux-android")
|
|
||||||
]
|
|
||||||
elif ARCH =="x86" or ARCH == "x86_64":
|
|
||||||
known_toolchains = [
|
|
||||||
("i686-android-linux" + gcc_version, "x86", "i686-android-linux")
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
known_toolchains = []
|
raise Exception("Could not find tool chain for %s" % (gcc_arch))
|
||||||
|
|
||||||
# Look for addr2line to check for valid toolchain path.
|
if not os.path.exists(ToolPath("addr2line", toolchain)):
|
||||||
for (label, platform, target) in known_toolchains:
|
raise Exception("No addr2line for %s" % (toolchain))
|
||||||
toolchain_info = (label, platform, target);
|
|
||||||
if os.path.exists(ToolPath("addr2line", toolchain_info)):
|
|
||||||
TOOLCHAIN_INFO = toolchain_info
|
|
||||||
print "Using toolchain from: " + ToolPath("", TOOLCHAIN_INFO)
|
|
||||||
return toolchain_info
|
|
||||||
|
|
||||||
raise Exception("Could not find tool chain for (%s, %s, %s)" % (label, platform, target))
|
TOOLCHAIN = toolchain
|
||||||
|
print "Using toolchain from: %s" % TOOLCHAIN
|
||||||
|
return TOOLCHAIN
|
||||||
|
|
||||||
def SymbolInformation(lib, addr):
|
def SymbolInformation(lib, addr):
|
||||||
"""Look up symbol information about an address.
|
"""Look up symbol information about an address.
|
||||||
@@ -202,7 +179,6 @@ def CallAddr2LineForSet(lib, unique_addrs):
|
|||||||
if not os.path.exists(symbols):
|
if not os.path.exists(symbols):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
(label, platform, target) = FindToolchain()
|
|
||||||
cmd = [ToolPath("addr2line"), "--functions", "--inlines",
|
cmd = [ToolPath("addr2line"), "--functions", "--inlines",
|
||||||
"--demangle", "--exe=" + symbols]
|
"--demangle", "--exe=" + symbols]
|
||||||
child = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
child = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
|
|||||||
Reference in New Issue
Block a user