diff options
author | Dean De Leo <dean@codeplay.com> | 2015-11-25 13:00:31 +0000 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2016-01-30 14:49:04 -0800 |
commit | fff398dc41bb579c7ad668387eebf9e3e972aeca (patch) | |
tree | 29eddfc2401e186b8c3284e785d156e2ed38b65d /bcinfo | |
parent | f0bc959d8d2397fedc45ba5b283cf6b4cd274ea4 (diff) | |
download | libbcc-fff398dc41bb579c7ad668387eebf9e3e972aeca.tar.gz |
Deduce whether the module contains debug info.
Add functionality to the MetadataExtractor to deduce whether the
module contains debug info. This method will be used to deduce
whether we should link with a special runtime library with debug
information.
Change-Id: I8ebe8c465c785adfb2b24864714e654f49c12c6d
Diffstat (limited to 'bcinfo')
-rw-r--r-- | bcinfo/MetadataExtractor.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bcinfo/MetadataExtractor.cpp b/bcinfo/MetadataExtractor.cpp index f190c48..96f3692 100644 --- a/bcinfo/MetadataExtractor.cpp +++ b/bcinfo/MetadataExtractor.cpp @@ -171,6 +171,11 @@ static const llvm::StringRef ThreadableMetadataName = "#rs_is_threadable"; // be synced with libbcc/lib/Core/Source.cpp) static const llvm::StringRef ChecksumMetadataName = "#rs_build_checksum"; +// Name of metadata node which contains a list of compile units that have debug +// metadata. If this is null then there is no debug metadata in the compile +// unit. +static const llvm::StringRef DebugInfoMetadataName = "llvm.dbg.cu"; + MetadataExtractor::MetadataExtractor(const char *bitcode, size_t bitcodeSize) : mModule(nullptr), mBitcode(bitcode), mBitcodeSize(bitcodeSize), mExportVarCount(0), mExportFuncCount(0), mExportForEachSignatureCount(0), @@ -182,7 +187,7 @@ MetadataExtractor::MetadataExtractor(const char *bitcode, size_t bitcodeSize) mPragmaCount(0), mPragmaKeyList(nullptr), mPragmaValueList(nullptr), mObjectSlotCount(0), mObjectSlotList(nullptr), mRSFloatPrecision(RS_FP_Full), mIsThreadable(true), - mBuildChecksum(nullptr) { + mBuildChecksum(nullptr), mHasDebugInfo(false) { BitcodeWrapper wrapper(bitcode, bitcodeSize); mTargetAPI = wrapper.getTargetAPI(); mCompilerVersion = wrapper.getCompilerVersion(); @@ -628,6 +633,8 @@ bool MetadataExtractor::extract() { mModule->getNamedMetadata(ThreadableMetadataName); const llvm::NamedMDNode *ChecksumMetadata = mModule->getNamedMetadata(ChecksumMetadataName); + const llvm::NamedMDNode *DebugInfoMetadata = + mModule->getNamedMetadata(DebugInfoMetadataName); if (!populateNameMetadata(ExportVarMetadata, mExportVarNameList, mExportVarCount)) { @@ -668,6 +675,8 @@ bool MetadataExtractor::extract() { readThreadableFlag(ThreadableMetadata); readBuildChecksumMetadata(ChecksumMetadata); + mHasDebugInfo = DebugInfoMetadata != nullptr; + return true; } |