<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">$ svn commit<br class="">Sending lib/DebugInfo/GSYM/Range.cpp<br class="">Transmitting file data .done<br class="">Committing transaction...<br class="">Committed revision 364447.<br class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 26, 2019, at 9:59 AM, Kostya Serebryany <<a href="mailto:kcc@google.com" class="">kcc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi, <div class=""><br class=""></div><div class="">I think this is causing a failure on the asan bot. </div><div class="">Please fix or revert ASAP</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/33102/steps/check-llvm%20asan/logs/stdio" class="">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/33102/steps/check-llvm%20asan/logs/stdio</a><br class=""></div><div class=""><pre style="font-family: "Courier New", courier, monotype, monospace; font-size: inherit;" class=""><span class="gmail-stdout">Note: Google Test filter = GSYMTest.TestRanges
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from GSYMTest
[ RUN ] GSYMTest.TestRanges
=================================================================
==19204==ERROR: AddressSanitizer: container-overflow on address 0x606000000390 at pc 0x00000052cde7 bp 0x7ffdbaad4740 sp 0x7ffdbaad4738
READ of size 8 at 0x606000000390 thread T0
#0 0x52cde6 in endAddress /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/DebugInfo/GSYM/Range.h:48:40
#1 0x52cde6 in intersects /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/DebugInfo/GSYM/Range.h:58
#2 0x52cde6 in intersect /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/DebugInfo/GSYM/Range.h:61
#3 0x52cde6 in llvm::gsym::AddressRanges::insert(llvm::gsym::AddressRange const&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/DebugInfo/GSYM/Range.cpp:35
#4 0x511b8d in GSYMTest_TestRanges_Test::TestBody() /b/sanitizer-x86_64-linux-fast/build/llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp:350:10</span></pre></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 26, 2019 at 7:09 AM Greg Clayton via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: gclayton<br class="">
Date: Wed Jun 26 07:09:09 2019<br class="">
New Revision: 364427<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=364427&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=364427&view=rev</a><br class="">
Log:<br class="">
Add GSYM utility files along with unit tests.<br class="">
<br class="">
The full GSYM patch started with: <a href="https://reviews.llvm.org/D53379" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D53379</a><br class="">
<br class="">
In that patch we wanted to split up getting GSYM into the LLVM code base so we are not committing too much code at once.<br class="">
<br class="">
This is a first in a series of patches where I only add the foundation classes along with complete unit tests. They provide the foundation for encoding and decoding a GSYM file.<br class="">
<br class="">
File entries are defined in llvm::gsym::FileEntry. This class splits the file up into a directory and filename represented by uniqued string table offsets. This allows all files that are referred to in a GSYM file to be encoded as 1 based indexes into a global file table in the GSYM file.<br class="">
<br class="">
Function information in stored in llvm::gsym::FunctionInfo. This object represents a contiguous address range that has a name and range with an optional line table and inline call stack information.<br class="">
<br class="">
Line table entries are defined in llvm::gsym::LineEntry. They store only address, file and line information to keep the line tables simple and allows the information to be efficiently encoded in a subsequent patch.<br class="">
<br class="">
Inline information is defined in llvm::gsym::InlineInfo. These structs store the name of the inline function, along with one or more address ranges, and the file and line that called this function. They also contain any child inline information.<br class="">
<br class="">
There are also utility classes for address ranges in llvm::gsym::AddressRange, and string table support in llvm::gsym::StringTable which are simple classes.<br class="">
<br class="">
The unit tests test all the APIs on these simple classes so they will be ready for the next patches where we will create GSYM files and parse GSYM files.<br class="">
<br class="">
Differential Revision: <a href="https://reviews.llvm.org/D63104" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D63104</a><br class="">
<br class="">
<br class="">
<br class="">
Added:<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/FileEntry.h<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/FunctionInfo.h<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/InlineInfo.h<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/LineEntry.h<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/Range.h<br class="">
llvm/trunk/include/llvm/DebugInfo/GSYM/StringTable.h<br class="">
llvm/trunk/lib/DebugInfo/GSYM/<br class="">
llvm/trunk/lib/DebugInfo/GSYM/CMakeLists.txt<br class="">
llvm/trunk/lib/DebugInfo/GSYM/FunctionInfo.cpp<br class="">
llvm/trunk/lib/DebugInfo/GSYM/InlineInfo.cpp<br class="">
llvm/trunk/lib/DebugInfo/GSYM/Range.cpp<br class="">
llvm/trunk/unittests/DebugInfo/GSYM/<br class="">
llvm/trunk/unittests/DebugInfo/GSYM/CMakeLists.txt<br class="">
llvm/trunk/unittests/DebugInfo/GSYM/GSYMTest.cpp<br class="">
Modified:<br class="">
llvm/trunk/lib/DebugInfo/CMakeLists.txt<br class="">
llvm/trunk/unittests/DebugInfo/CMakeLists.txt<br class="">
<br class="">
Added: llvm/trunk/include/llvm/DebugInfo/GSYM/FileEntry.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/FileEntry.h?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/FileEntry.h?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/DebugInfo/GSYM/FileEntry.h (added)<br class="">
+++ llvm/trunk/include/llvm/DebugInfo/GSYM/FileEntry.h Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,69 @@<br class="">
+//===- FileEntry.h ----------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H<br class="">
+#define LLVM_DEBUGINFO_GSYM_FILEENTRY_H<br class="">
+<br class="">
+#include "llvm/ADT/DenseMapInfo.h"<br class="">
+#include "llvm/ADT/Hashing.h"<br class="">
+#include <functional><br class="">
+#include <stdint.h><br class="">
+#include <utility><br class="">
+<br class="">
+namespace llvm {<br class="">
+namespace gsym {<br class="">
+<br class="">
+/// Files in GSYM are contained in FileEntry structs where we split the <br class="">
+/// directory and basename into two different strings in the string <br class="">
+/// table. This allows paths to shared commont directory and filename<br class="">
+/// strings and saves space.<br class="">
+struct FileEntry {<br class="">
+<br class="">
+ /// Offsets in the string table.<br class="">
+ /// @{<br class="">
+ uint32_t Dir = 0;<br class="">
+ uint32_t Base = 0;<br class="">
+ /// @}<br class="">
+<br class="">
+ FileEntry() = default;<br class="">
+ FileEntry(uint32_t D, uint32_t B) : Dir(D), Base(B) {}<br class="">
+<br class="">
+ // Implement operator== so that FileEntry can be used as key in<br class="">
+ // unordered containers.<br class="">
+ bool operator==(const FileEntry &RHS) const {<br class="">
+ return Base == RHS.Base && Dir == RHS.Dir;<br class="">
+ };<br class="">
+ bool operator!=(const FileEntry &RHS) const {<br class="">
+ return Base != RHS.Base || Dir != RHS.Dir;<br class="">
+ };<br class="">
+};<br class="">
+<br class="">
+} // namespace gsym<br class="">
+<br class="">
+template <> struct DenseMapInfo<gsym::FileEntry> {<br class="">
+ static inline gsym::FileEntry getEmptyKey() {<br class="">
+ const auto key = DenseMapInfo<uint32_t>::getEmptyKey();<br class="">
+ return gsym::FileEntry(key, key);<br class="">
+ <br class="">
+ }<br class="">
+ static inline gsym::FileEntry getTombstoneKey() {<br class="">
+ const auto key = DenseMapInfo<uint32_t>::getTombstoneKey();<br class="">
+ return gsym::FileEntry(key, key);<br class="">
+ }<br class="">
+ static unsigned getHashValue(const gsym::FileEntry &Val) {<br class="">
+ return llvm::hash_combine(DenseMapInfo<uint32_t>::getHashValue(Val.Dir),<br class="">
+ DenseMapInfo<uint32_t>::getHashValue(Val.Base));<br class="">
+ }<br class="">
+ static bool isEqual(const gsym::FileEntry &LHS, const gsym::FileEntry &RHS) {<br class="">
+ return LHS == RHS;<br class="">
+ }<br class="">
+};<br class="">
+<br class="">
+} // namespace llvm<br class="">
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_FILEENTRY_H<br class="">
<br class="">
Added: llvm/trunk/include/llvm/DebugInfo/GSYM/FunctionInfo.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/FunctionInfo.h?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/FunctionInfo.h?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/DebugInfo/GSYM/FunctionInfo.h (added)<br class="">
+++ llvm/trunk/include/llvm/DebugInfo/GSYM/FunctionInfo.h Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,107 @@<br class="">
+//===- FunctionInfo.h -------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H<br class="">
+#define LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H<br class="">
+<br class="">
+#include "llvm/DebugInfo/GSYM/InlineInfo.h"<br class="">
+#include "llvm/DebugInfo/GSYM/LineEntry.h"<br class="">
+#include "llvm/DebugInfo/GSYM/Range.h"<br class="">
+#include "llvm/DebugInfo/GSYM/StringTable.h"<br class="">
+#include <tuple><br class="">
+#include <vector><br class="">
+<br class="">
+namespace llvm {<br class="">
+class raw_ostream;<br class="">
+namespace gsym {<br class="">
+<br class="">
+/// Function information in GSYM files encodes information for one <br class="">
+/// contiguous address range. The name of the function is encoded as<br class="">
+/// a string table offset and allows multiple functions with the same<br class="">
+/// name to share the name string in the string table. Line tables are<br class="">
+/// stored in a sorted vector of gsym::LineEntry objects and are split<br class="">
+/// into line tables for each function. If a function has a discontiguous<br class="">
+/// range, it will be split into two gsym::FunctionInfo objects. If the<br class="">
+/// function has inline functions, the information will be encoded in<br class="">
+/// the "Inline" member, see gsym::InlineInfo for more information.<br class="">
+struct FunctionInfo {<br class="">
+ AddressRange Range;<br class="">
+ uint32_t Name; ///< String table offset in the string table.<br class="">
+ std::vector<gsym::LineEntry> Lines;<br class="">
+ InlineInfo Inline;<br class="">
+<br class="">
+ FunctionInfo(uint64_t Addr = 0, uint64_t Size = 0, uint32_t N = 0)<br class="">
+ : Range(Addr, Addr + Size), Name(N) {}<br class="">
+<br class="">
+ bool hasRichInfo() const {<br class="">
+ /// Returns whether we have something else than range and name. When<br class="">
+ /// converting information from a symbol table and from debug info, we <br class="">
+ /// might end up with multiple FunctionInfo objects for the same range<br class="">
+ /// and we need to be able to tell which one is the better object to use.<br class="">
+ return !Lines.empty() || Inline.isValid();<br class="">
+ }<br class="">
+<br class="">
+ bool isValid() const {<br class="">
+ /// Address and size can be zero and there can be no line entries for a<br class="">
+ /// symbol so the only indication this entry is valid is if the name is<br class="">
+ /// not zero. This can happen when extracting information from symbol <br class="">
+ /// tables that do not encode symbol sizes. In that case only the <br class="">
+ /// address and name will be filled in.<br class="">
+ return Name != 0;<br class="">
+ }<br class="">
+<br class="">
+ uint64_t startAddress() const { return Range.startAddress(); }<br class="">
+ uint64_t endAddress() const { return Range.endAddress(); }<br class="">
+ uint64_t size() const { return Range.size(); }<br class="">
+ void setStartAddress(uint64_t Addr) { Range.setStartAddress(Addr); }<br class="">
+ void setEndAddress(uint64_t Addr) { Range.setEndAddress(Addr); }<br class="">
+ void setSize(uint64_t Size) { Range.setSize(Size); }<br class="">
+<br class="">
+ void clear() {<br class="">
+ Range.clear();<br class="">
+ Name = 0;<br class="">
+ Lines.clear();<br class="">
+ Inline.clear();<br class="">
+ }<br class="">
+};<br class="">
+<br class="">
+inline bool operator==(const FunctionInfo &LHS, const FunctionInfo &RHS) {<br class="">
+ return LHS.Range == RHS.Range && LHS.Name == RHS.Name &&<br class="">
+ LHS.Lines == RHS.Lines && LHS.Inline == RHS.Inline;<br class="">
+}<br class="">
+inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) {<br class="">
+ return !(LHS == RHS);<br class="">
+}<br class="">
+/// This sorting will order things consistently by address range first, but then<br class="">
+/// followed by inlining being valid and line tables. We might end up with a<br class="">
+/// FunctionInfo from debug info that will have the same range as one from the<br class="">
+/// symbol table, but we want to quickly be able to sort and use the best version<br class="">
+/// when creating the final GSYM file. <br class="">
+inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) {<br class="">
+ // First sort by address range<br class="">
+ if (LHS.Range != RHS.Range)<br class="">
+ return LHS.Range < RHS.Range;<br class="">
+<br class="">
+ // Then sort by inline<br class="">
+ if (LHS.Inline.isValid() != RHS.Inline.isValid())<br class="">
+ return RHS.Inline.isValid();<br class="">
+<br class="">
+ // If the number of lines is the same, then compare line table entries<br class="">
+ if (LHS.Lines.size() == RHS.Lines.size())<br class="">
+ return LHS.Lines < RHS.Lines;<br class="">
+ // Then sort by number of line table entries (more is better)<br class="">
+ return LHS.Lines.size() < RHS.Lines.size();<br class="">
+}<br class="">
+<br class="">
+raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R);<br class="">
+<br class="">
+} // namespace gsym<br class="">
+} // namespace llvm<br class="">
+<br class="">
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_FUNCTIONINFO_H<br class="">
<br class="">
Added: llvm/trunk/include/llvm/DebugInfo/GSYM/InlineInfo.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/InlineInfo.h?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/InlineInfo.h?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/DebugInfo/GSYM/InlineInfo.h (added)<br class="">
+++ llvm/trunk/include/llvm/DebugInfo/GSYM/InlineInfo.h Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,77 @@<br class="">
+//===- InlineInfo.h ---------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H<br class="">
+#define LLVM_DEBUGINFO_GSYM_INLINEINFO_H<br class="">
+<br class="">
+#include "llvm/ADT/Optional.h"<br class="">
+#include "llvm/DebugInfo/GSYM/Range.h"<br class="">
+#include <stdint.h><br class="">
+#include <vector><br class="">
+<br class="">
+<br class="">
+namespace llvm {<br class="">
+class raw_ostream;<br class="">
+<br class="">
+namespace gsym {<br class="">
+<br class="">
+/// Inline information stores the name of the inline function along with<br class="">
+/// an array of address ranges. It also stores the call file and call line<br class="">
+/// that called this inline function. This allows us to unwind inline call <br class="">
+/// stacks back to the inline or concrete function that called this <br class="">
+/// function. Inlined functions contained in this function are stored in the<br class="">
+/// "Children" variable. All address ranges must be sorted and all address<br class="">
+/// ranges of all children must be contained in the ranges of this function.<br class="">
+/// Any clients that encode information will need to ensure the ranges are<br class="">
+/// all contined correctly or lookups could fail. Add ranges in these objects<br class="">
+/// must be contained in the top level FunctionInfo address ranges as well.<br class="">
+struct InlineInfo {<br class="">
+<br class="">
+ uint32_t Name; ///< String table offset in the string table.<br class="">
+ uint32_t CallFile; ///< 1 based file index in the file table.<br class="">
+ uint32_t CallLine; ///< Source line number.<br class="">
+ AddressRanges Ranges;<br class="">
+ std::vector<InlineInfo> Children;<br class="">
+ InlineInfo() : Name(0), CallFile(0), CallLine(0) {}<br class="">
+ void clear() {<br class="">
+ Name = 0;<br class="">
+ CallFile = 0;<br class="">
+ CallLine = 0;<br class="">
+ Ranges.clear();<br class="">
+ Children.clear();<br class="">
+ }<br class="">
+ bool isValid() const { return !Ranges.empty(); }<br class="">
+ /// Lookup an address in the InlineInfo object<br class="">
+ ///<br class="">
+ /// This function is used to symbolicate an inline call stack and can <br class="">
+ /// turn one address in the program into one or more inline call stacks<br class="">
+ /// and have the stack trace show the original call site from <br class="">
+ /// non-inlined code.<br class="">
+ ///<br class="">
+ /// \param Addr the address to lookup<br class="">
+ /// \param InlineStack a vector of InlineInfo objects that describe the<br class="">
+ /// inline call stack for a given address.<br class="">
+ ///<br class="">
+ /// \returns true if successful, false otherwise<br class="">
+ typedef std::vector<const InlineInfo *> InlineArray;<br class="">
+ llvm::Optional<InlineArray> getInlineStack(uint64_t Addr) const;<br class="">
+};<br class="">
+<br class="">
+inline bool operator==(const InlineInfo &LHS, const InlineInfo &RHS) {<br class="">
+ return LHS.Name == RHS.Name && LHS.CallFile == RHS.CallFile &&<br class="">
+ LHS.CallLine == RHS.CallLine && LHS.Ranges == RHS.Ranges &&<br class="">
+ LHS.Children == RHS.Children;<br class="">
+}<br class="">
+<br class="">
+raw_ostream &operator<<(raw_ostream &OS, const InlineInfo &FI);<br class="">
+<br class="">
+} // namespace gsym<br class="">
+} // namespace llvm<br class="">
+<br class="">
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_INLINEINFO_H<br class="">
<br class="">
Added: llvm/trunk/include/llvm/DebugInfo/GSYM/LineEntry.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/LineEntry.h?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/LineEntry.h?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/DebugInfo/GSYM/LineEntry.h (added)<br class="">
+++ llvm/trunk/include/llvm/DebugInfo/GSYM/LineEntry.h Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,48 @@<br class="">
+//===- LineEntry.h ----------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H<br class="">
+#define LLVM_DEBUGINFO_GSYM_LINEENTRY_H<br class="">
+<br class="">
+#include "llvm/DebugInfo/GSYM/Range.h"<br class="">
+<br class="">
+namespace llvm {<br class="">
+namespace gsym {<br class="">
+<br class="">
+/// Line entries are used to encode the line tables in FunctionInfo objects.<br class="">
+/// They are stored as a sorted vector of these objects and store the<br class="">
+/// address, file and line of the line table row for a given address. The<br class="">
+/// size of a line table entry is calculated by looking at the next entry<br class="">
+/// in the FunctionInfo's vector of entries.<br class="">
+struct LineEntry {<br class="">
+ uint64_t Addr; ///< Start address of this line entry.<br class="">
+ uint32_t File; ///< 1 based index of file in FileTable<br class="">
+ uint32_t Line; ///< Source line number.<br class="">
+ LineEntry(uint64_t A = 0, uint32_t F = 0, uint32_t L = 0)<br class="">
+ : Addr(A), File(F), Line(L) {}<br class="">
+ bool isValid() { return File != 0; }<br class="">
+};<br class="">
+<br class="">
+inline raw_ostream &operator<<(raw_ostream &OS, const LineEntry &LE) {<br class="">
+ return OS << "addr=" << HEX64(LE.Addr) << ", file=" << format("%3u", LE.File) <br class="">
+ << ", line=" << format("%3u", LE.Line);<br class="">
+}<br class="">
+<br class="">
+inline bool operator==(const LineEntry &LHS, const LineEntry &RHS) {<br class="">
+ return LHS.Addr == RHS.Addr && LHS.File == RHS.File && LHS.Line == RHS.Line;<br class="">
+}<br class="">
+inline bool operator!=(const LineEntry &LHS, const LineEntry &RHS) {<br class="">
+ return !(LHS == RHS);<br class="">
+}<br class="">
+inline bool operator<(const LineEntry &LHS, const LineEntry &RHS) {<br class="">
+ return LHS.Addr < RHS.Addr;<br class="">
+}<br class="">
+} // namespace gsym<br class="">
+} // namespace llvm<br class="">
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_LINEENTRY_H<br class="">
<br class="">
Added: llvm/trunk/include/llvm/DebugInfo/GSYM/Range.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/Range.h?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/Range.h?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/DebugInfo/GSYM/Range.h (added)<br class="">
+++ llvm/trunk/include/llvm/DebugInfo/GSYM/Range.h Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,123 @@<br class="">
+//===- AddressRange.h -------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#ifndef LLVM_DEBUGINFO_GSYM_RANGE_H<br class="">
+#define LLVM_DEBUGINFO_GSYM_RANGE_H<br class="">
+<br class="">
+#include "llvm/Support/Format.h"<br class="">
+#include "llvm/Support/raw_ostream.h"<br class="">
+#include <stdint.h><br class="">
+#include <vector><br class="">
+<br class="">
+#define HEX8(v) llvm::format_hex(v, 4)<br class="">
+#define HEX16(v) llvm::format_hex(v, 6)<br class="">
+#define HEX32(v) llvm::format_hex(v, 10)<br class="">
+#define HEX64(v) llvm::format_hex(v, 18)<br class="">
+<br class="">
+namespace llvm {<br class="">
+class raw_ostream;<br class="">
+<br class="">
+namespace gsym {<br class="">
+<br class="">
+/// A class that represents an address range. The range is specified using<br class="">
+/// a start and an end address. <br class="">
+class AddressRange {<br class="">
+ uint64_t Start;<br class="">
+ uint64_t End;<br class="">
+public:<br class="">
+ AddressRange(uint64_t S = 0, uint64_t E = 0) : Start(S), End(E) {}<br class="">
+ /// Access to the size must use the size() accessor to ensure the correct<br class="">
+ /// answer. This allows an AddressRange to be constructed with invalid<br class="">
+ /// address ranges where the end address is less that the start address<br class="">
+ /// either because it was not set, or because of incorrect data.<br class="">
+ uint64_t size() const { return Start < End ? End - Start : 0; }<br class="">
+ void setStartAddress(uint64_t Addr) { Start = Addr; }<br class="">
+ void setEndAddress(uint64_t Addr) { End = Addr; }<br class="">
+ void setSize(uint64_t Size) { End = Start + Size; }<br class="">
+ uint64_t startAddress() const { return Start; }<br class="">
+ /// Access to the end address must use the size() accessor to ensure the<br class="">
+ /// correct answer. This allows an AddressRange to be constructed with<br class="">
+ /// invalid address ranges where the end address is less that the start <br class="">
+ /// address either because it was not set, or because of incorrect data.<br class="">
+ uint64_t endAddress() const { return Start + size(); }<br class="">
+ void clear() {<br class="">
+ Start = 0;<br class="">
+ End = 0;<br class="">
+ }<br class="">
+ bool contains(uint64_t Addr) const { return Start <= Addr && Addr < endAddress(); }<br class="">
+ bool isContiguousWith(const AddressRange &R) const {<br class="">
+ return (Start <= R.endAddress()) && (endAddress() >= R.Start);<br class="">
+ }<br class="">
+ bool intersects(const AddressRange &R) const {<br class="">
+ return (Start < R.endAddress()) && (endAddress() > R.Start);<br class="">
+ }<br class="">
+ bool intersect(const AddressRange &R) {<br class="">
+ if (intersects(R)) {<br class="">
+ Start = std::min<uint64_t>(Start, R.Start);<br class="">
+ End = std::max<uint64_t>(endAddress(), R.endAddress());<br class="">
+ return true;<br class="">
+ }<br class="">
+ return false;<br class="">
+ }<br class="">
+};<br class="">
+<br class="">
+inline bool operator==(const AddressRange &LHS, const AddressRange &RHS) {<br class="">
+ return LHS.startAddress() == RHS.startAddress() && LHS.endAddress() == RHS.endAddress();<br class="">
+}<br class="">
+inline bool operator!=(const AddressRange &LHS, const AddressRange &RHS) {<br class="">
+ return LHS.startAddress() != RHS.startAddress() || LHS.endAddress() != RHS.endAddress();<br class="">
+}<br class="">
+inline bool operator<(const AddressRange &LHS, const AddressRange &RHS) {<br class="">
+ if (LHS.startAddress() == RHS.startAddress())<br class="">
+ return LHS.endAddress() < RHS.endAddress();<br class="">
+ return LHS.startAddress() < RHS.startAddress();<br class="">
+}<br class="">
+inline bool operator<(const AddressRange &LHS, uint64_t Addr) {<br class="">
+ return LHS.startAddress() < Addr;<br class="">
+}<br class="">
+inline bool operator<(uint64_t Addr, const AddressRange &RHS) {<br class="">
+ return Addr < RHS.startAddress();<br class="">
+}<br class="">
+<br class="">
+raw_ostream &operator<<(raw_ostream &OS, const AddressRange &R);<br class="">
+<br class="">
+/// The AddressRanges class helps normalize address range collections.<br class="">
+/// This class keeps a sorted vector of AddressRange objects and can perform<br class="">
+/// insertions and searches efficiently. The address ranges are always sorted<br class="">
+/// and never contain any invalid or empty address ranges. This allows us to<br class="">
+/// emit address ranges into the GSYM file efficiently. Intersecting address<br class="">
+/// ranges are combined during insertion so that we can emit the most compact<br class="">
+/// representation for address ranges when writing to disk.<br class="">
+class AddressRanges {<br class="">
+protected:<br class="">
+ typedef std::vector<AddressRange> Collection;<br class="">
+ Collection Ranges;<br class="">
+public:<br class="">
+ void clear() { Ranges.clear(); }<br class="">
+ bool empty() const { return Ranges.empty(); }<br class="">
+ bool contains(uint64_t Addr) const;<br class="">
+ void insert(const AddressRange &R);<br class="">
+ size_t size() const { return Ranges.size(); }<br class="">
+ bool operator==(const AddressRanges &RHS) const {<br class="">
+ return Ranges == RHS.Ranges;<br class="">
+ }<br class="">
+ const AddressRange &operator[](size_t i) const {<br class="">
+ assert(i < Ranges.size());<br class="">
+ return Ranges[i];<br class="">
+ }<br class="">
+ Collection::const_iterator begin() const { return Ranges.begin(); }<br class="">
+ Collection::const_iterator end() const { return Ranges.end(); }<br class="">
+};<br class="">
+<br class="">
+raw_ostream &operator<<(raw_ostream &OS, const AddressRanges &AR);<br class="">
+<br class="">
+} // namespace gsym<br class="">
+} // namespace llvm<br class="">
+<br class="">
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_RANGE_H<br class="">
<br class="">
Added: llvm/trunk/include/llvm/DebugInfo/GSYM/StringTable.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/StringTable.h?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/GSYM/StringTable.h?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/DebugInfo/GSYM/StringTable.h (added)<br class="">
+++ llvm/trunk/include/llvm/DebugInfo/GSYM/StringTable.h Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,54 @@<br class="">
+//===- StringTable.h --------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H<br class="">
+#define LLVM_DEBUGINFO_GSYM_STRINGTABLE_H<br class="">
+<br class="">
+#include "llvm/ADT/Optional.h"<br class="">
+#include "llvm/ADT/StringRef.h"<br class="">
+#include "llvm/DebugInfo/GSYM/Range.h"<br class="">
+#include <stdint.h><br class="">
+#include <string><br class="">
+<br class="">
+<br class="">
+namespace llvm {<br class="">
+namespace gsym {<br class="">
+<br class="">
+/// String tables in GSYM files are required to start with an empty <br class="">
+/// string at offset zero. Strings must be UTF8 NULL terminated strings.<br class="">
+struct StringTable {<br class="">
+ StringRef Data;<br class="">
+ StringTable() : Data() {}<br class="">
+ StringTable(StringRef D) : Data(D) {}<br class="">
+ StringRef operator[](size_t Offset) const { return getString(Offset); }<br class="">
+ StringRef getString(uint32_t Offset) const {<br class="">
+ if (Offset < Data.size()) {<br class="">
+ auto End = Data.find('\0', Offset);<br class="">
+ return Data.substr(Offset, End - Offset);<br class="">
+ }<br class="">
+ return StringRef();<br class="">
+ }<br class="">
+ void clear() { Data = StringRef(); }<br class="">
+};<br class="">
+<br class="">
+inline raw_ostream &operator<<(raw_ostream &OS, const StringTable &S) {<br class="">
+ OS << "String table:\n";<br class="">
+ uint32_t Offset = 0;<br class="">
+ const size_t Size = S.Data.size();<br class="">
+ while (Offset < Size) {<br class="">
+ StringRef Str = S.getString(Offset);<br class="">
+ OS << HEX32(Offset) << ": \"" << Str << "\"\n";<br class="">
+ Offset += Str.size() + 1;<br class="">
+ }<br class="">
+ return OS;<br class="">
+}<br class="">
+<br class="">
+} // namespace gsym<br class="">
+} // namespace llvm<br class="">
+#endif // #ifndef LLVM_DEBUGINFO_GSYM_STRINGTABLE_H<br class="">
<br class="">
Modified: llvm/trunk/lib/DebugInfo/CMakeLists.txt<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CMakeLists.txt?rev=364427&r1=364426&r2=364427&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CMakeLists.txt?rev=364427&r1=364426&r2=364427&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/DebugInfo/CMakeLists.txt (original)<br class="">
+++ llvm/trunk/lib/DebugInfo/CMakeLists.txt Wed Jun 26 07:09:09 2019<br class="">
@@ -1,4 +1,5 @@<br class="">
add_subdirectory(DWARF)<br class="">
+add_subdirectory(GSYM)<br class="">
add_subdirectory(MSF)<br class="">
add_subdirectory(CodeView)<br class="">
add_subdirectory(PDB)<br class="">
<br class="">
Added: llvm/trunk/lib/DebugInfo/GSYM/CMakeLists.txt<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/CMakeLists.txt?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/CMakeLists.txt?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/DebugInfo/GSYM/CMakeLists.txt (added)<br class="">
+++ llvm/trunk/lib/DebugInfo/GSYM/CMakeLists.txt Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,9 @@<br class="">
+add_llvm_library(LLVMDebugInfoGSYM<br class="">
+ FunctionInfo.cpp<br class="">
+ InlineInfo.cpp<br class="">
+ Range.cpp<br class="">
+<br class="">
+ ADDITIONAL_HEADER_DIRS<br class="">
+ ${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo/GSYM<br class="">
+ ${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo<br class="">
+ )<br class="">
<br class="">
Added: llvm/trunk/lib/DebugInfo/GSYM/FunctionInfo.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/FunctionInfo.cpp?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/FunctionInfo.cpp?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/DebugInfo/GSYM/FunctionInfo.cpp (added)<br class="">
+++ llvm/trunk/lib/DebugInfo/GSYM/FunctionInfo.cpp Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,23 @@<br class="">
+//===- FunctionInfo.cpp -----------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#include "llvm/DebugInfo/GSYM/FunctionInfo.h"<br class="">
+<br class="">
+using namespace llvm;<br class="">
+using namespace gsym;<br class="">
+<br class="">
+raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const FunctionInfo &FI) {<br class="">
+ OS << '[' << HEX64(FI.Range.startAddress()) << '-'<br class="">
+ << HEX64(FI.Range.endAddress()) << "): "<br class="">
+ << "Name=" << HEX32(FI.Name) << '\n';<br class="">
+ for (const auto &Line : FI.Lines)<br class="">
+ OS << Line << '\n';<br class="">
+ OS << FI.Inline;<br class="">
+ return OS;<br class="">
+}<br class="">
<br class="">
Added: llvm/trunk/lib/DebugInfo/GSYM/InlineInfo.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/InlineInfo.cpp?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/InlineInfo.cpp?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/DebugInfo/GSYM/InlineInfo.cpp (added)<br class="">
+++ llvm/trunk/lib/DebugInfo/GSYM/InlineInfo.cpp Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,59 @@<br class="">
+//===- InlineInfo.cpp -------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#include "llvm/DebugInfo/GSYM/FileEntry.h"<br class="">
+#include "llvm/DebugInfo/GSYM/InlineInfo.h"<br class="">
+#include <algorithm><br class="">
+#include <inttypes.h><br class="">
+<br class="">
+using namespace llvm;<br class="">
+using namespace gsym;<br class="">
+<br class="">
+<br class="">
+raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const InlineInfo &II) {<br class="">
+ if (!II.isValid())<br class="">
+ return OS;<br class="">
+ bool First = true;<br class="">
+ for (auto Range : II.Ranges) {<br class="">
+ if (First)<br class="">
+ First = false;<br class="">
+ else<br class="">
+ OS << ' ';<br class="">
+ OS << Range;<br class="">
+ }<br class="">
+ OS << " Name = " << HEX32(II.Name) << ", CallFile = " << II.CallFile<br class="">
+ << ", CallLine = " << II.CallFile << '\n';<br class="">
+ for (const auto &Child : II.Children)<br class="">
+ OS << Child;<br class="">
+ return OS;<br class="">
+}<br class="">
+<br class="">
+static bool getInlineStackHelper(const InlineInfo &II, uint64_t Addr, <br class="">
+ std::vector<const InlineInfo *> &InlineStack) {<br class="">
+ if (II.Ranges.contains(Addr)) {<br class="">
+ // If this is the top level that represents the concrete function,<br class="">
+ // there will be no name and we shoud clear the inline stack. Otherwise<br class="">
+ // we have found an inline call stack that we need to insert.<br class="">
+ if (II.Name != 0)<br class="">
+ InlineStack.insert(InlineStack.begin(), &II);<br class="">
+ for (const auto &Child : II.Children) {<br class="">
+ if (::getInlineStackHelper(Child, Addr, InlineStack))<br class="">
+ break;<br class="">
+ }<br class="">
+ return !InlineStack.empty();<br class="">
+ }<br class="">
+ return false;<br class="">
+}<br class="">
+<br class="">
+llvm::Optional<InlineInfo::InlineArray> InlineInfo::getInlineStack(uint64_t Addr) const {<br class="">
+ InlineArray Result;<br class="">
+ if (getInlineStackHelper(*this, Addr, Result))<br class="">
+ return Result;<br class="">
+ return llvm::None;<br class="">
+}<br class="">
<br class="">
Added: llvm/trunk/lib/DebugInfo/GSYM/Range.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/Range.cpp?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/GSYM/Range.cpp?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/DebugInfo/GSYM/Range.cpp (added)<br class="">
+++ llvm/trunk/lib/DebugInfo/GSYM/Range.cpp Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,71 @@<br class="">
+//===- Range.cpp ------------------------------------------------*- C++ -*-===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#include "llvm/DebugInfo/GSYM/Range.h"<br class="">
+#include <algorithm><br class="">
+#include <inttypes.h><br class="">
+<br class="">
+using namespace llvm;<br class="">
+using namespace gsym;<br class="">
+<br class="">
+<br class="">
+void AddressRanges::insert(const AddressRange &Range) {<br class="">
+ if (Range.size() == 0)<br class="">
+ return;<br class="">
+ // Ranges.insert(std::upper_bound(Ranges.begin(), Ranges.end(), Range), Range);<br class="">
+<br class="">
+ // // Check if an existing range intersects with this range, and if so, <br class="">
+ // // grow the intersecting ranges instead of adding a new one.<br class="">
+ auto Begin = Ranges.begin();<br class="">
+ auto End = Ranges.end();<br class="">
+ const auto Iter = std::upper_bound(Begin, End, Range);<br class="">
+ if (Iter != Begin) {<br class="">
+ auto PrevIter = Iter - 1;<br class="">
+ // If the previous range itersects with "Range" they will be combined.<br class="">
+ if (PrevIter->intersect(Range)) {<br class="">
+ // Now check if the previous range intersects with the next range since<br class="">
+ // the previous range was combined. If so, combine them and remove the<br class="">
+ // next range.<br class="">
+ if (PrevIter->intersect(*Iter))<br class="">
+ Ranges.erase(Iter);<br class="">
+ return;<br class="">
+ }<br class="">
+ }<br class="">
+ // If the next range intersects with "Range", combined and return.<br class="">
+ if (Iter != End && Iter->intersect(Range))<br class="">
+ return;<br class="">
+ Ranges.insert(Iter, Range);<br class="">
+}<br class="">
+<br class="">
+bool AddressRanges::contains(uint64_t Addr) const {<br class="">
+ if (Ranges.empty())<br class="">
+ return false;<br class="">
+ auto Begin = Ranges.begin();<br class="">
+ auto Pos = std::upper_bound(Begin, Ranges.end(), Addr);<br class="">
+ if (Pos == Begin)<br class="">
+ return false;<br class="">
+ --Pos;<br class="">
+ return Pos->contains(Addr);<br class="">
+}<br class="">
+<br class="">
+raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const AddressRange &R) {<br class="">
+ return OS << '[' << HEX64(R.startAddress()) << " - " << HEX64(R.endAddress())<br class="">
+ << ")";<br class="">
+}<br class="">
+<br class="">
+raw_ostream &llvm::gsym::operator<<(raw_ostream &OS, const AddressRanges &AR) {<br class="">
+ size_t Size = AR.size();<br class="">
+ for (size_t I=0; I<Size; ++I) {<br class="">
+ if (I)<br class="">
+ OS << ' ';<br class="">
+ OS << AR[I];<br class="">
+ }<br class="">
+ return OS;<br class="">
+}<br class="">
+<br class="">
<br class="">
Modified: llvm/trunk/unittests/DebugInfo/CMakeLists.txt<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/CMakeLists.txt?rev=364427&r1=364426&r2=364427&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/CMakeLists.txt?rev=364427&r1=364426&r2=364427&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/unittests/DebugInfo/CMakeLists.txt (original)<br class="">
+++ llvm/trunk/unittests/DebugInfo/CMakeLists.txt Wed Jun 26 07:09:09 2019<br class="">
@@ -1,4 +1,5 @@<br class="">
add_subdirectory(CodeView)<br class="">
add_subdirectory(DWARF)<br class="">
+add_subdirectory(GSYM)<br class="">
add_subdirectory(MSF)<br class="">
add_subdirectory(PDB)<br class="">
<br class="">
Added: llvm/trunk/unittests/DebugInfo/GSYM/CMakeLists.txt<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/GSYM/CMakeLists.txt?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/GSYM/CMakeLists.txt?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/unittests/DebugInfo/GSYM/CMakeLists.txt (added)<br class="">
+++ llvm/trunk/unittests/DebugInfo/GSYM/CMakeLists.txt Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,15 @@<br class="">
+set(LLVM_LINK_COMPONENTS<br class="">
+ ${LLVM_TARGETS_TO_BUILD}<br class="">
+ AsmPrinter<br class="">
+ DebugInfoGSYM<br class="">
+ MC<br class="">
+ Object<br class="">
+ ObjectYAML<br class="">
+ Support<br class="">
+ )<br class="">
+<br class="">
+add_llvm_unittest(DebugInfoGSYMTests<br class="">
+ GSYMTest.cpp<br class="">
+ )<br class="">
+<br class="">
+target_link_libraries(DebugInfoGSYMTests PRIVATE LLVMTestingSupport)<br class="">
<br class="">
Added: llvm/trunk/unittests/DebugInfo/GSYM/GSYMTest.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/GSYM/GSYMTest.cpp?rev=364427&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/GSYM/GSYMTest.cpp?rev=364427&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/unittests/DebugInfo/GSYM/GSYMTest.cpp (added)<br class="">
+++ llvm/trunk/unittests/DebugInfo/GSYM/GSYMTest.cpp Wed Jun 26 07:09:09 2019<br class="">
@@ -0,0 +1,390 @@<br class="">
+//===- llvm/unittest/DebugInfo/GSYMTest.cpp -------------------------------===//<br class="">
+//<br class="">
+// The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+<br class="">
+#include "llvm/ADT/DenseMap.h"<br class="">
+#include "llvm/DebugInfo/GSYM/FileEntry.h"<br class="">
+#include "llvm/DebugInfo/GSYM/FunctionInfo.h"<br class="">
+#include "llvm/DebugInfo/GSYM/InlineInfo.h"<br class="">
+#include "llvm/DebugInfo/GSYM/Range.h"<br class="">
+#include "llvm/DebugInfo/GSYM/StringTable.h"<br class="">
+#include "llvm/Testing/Support/Error.h"<br class="">
+<br class="">
+#include "gtest/gtest.h"<br class="">
+#include <sstream><br class="">
+#include <string><br class="">
+<br class="">
+using namespace llvm;<br class="">
+using namespace gsym;<br class="">
+<br class="">
+TEST(GSYMTest, TestFileEntry) {<br class="">
+ // Make sure default constructed GSYM FileEntry has zeroes in the <br class="">
+ // directory and basename string table indexes.<br class="">
+ FileEntry empty1;<br class="">
+ FileEntry empty2;<br class="">
+ EXPECT_EQ(empty1.Dir, 0u);<br class="">
+ EXPECT_EQ(empty1.Base, 0u);<br class="">
+ // Verify equality operator works<br class="">
+ FileEntry a1(10,30);<br class="">
+ FileEntry a2(10,30);<br class="">
+ FileEntry b(10,40);<br class="">
+ EXPECT_EQ(empty1, empty2);<br class="">
+ EXPECT_EQ(a1, a2);<br class="">
+ EXPECT_NE(a1, b);<br class="">
+ EXPECT_NE(a1, empty1);<br class="">
+ // Test we can use llvm::gsym::FileEntry in llvm::DenseMap.<br class="">
+ DenseMap<FileEntry, uint32_t> EntryToIndex;<br class="">
+ constexpr uint32_t Index1 = 1;<br class="">
+ constexpr uint32_t Index2 = 1;<br class="">
+ auto R = EntryToIndex.insert(std::make_pair(a1, Index1));<br class="">
+ EXPECT_TRUE(R.second);<br class="">
+ EXPECT_EQ(R.first->second, Index1);<br class="">
+ R = EntryToIndex.insert(std::make_pair(a1, Index1));<br class="">
+ EXPECT_FALSE(R.second);<br class="">
+ EXPECT_EQ(R.first->second, Index1);<br class="">
+ R = EntryToIndex.insert(std::make_pair(b, Index2));<br class="">
+ EXPECT_TRUE(R.second);<br class="">
+ EXPECT_EQ(R.first->second, Index2);<br class="">
+ R = EntryToIndex.insert(std::make_pair(a1, Index2));<br class="">
+ EXPECT_FALSE(R.second);<br class="">
+ EXPECT_EQ(R.first->second, Index2);<br class="">
+}<br class="">
+<br class="">
+<br class="">
+TEST(GSYMTest, TestFunctionInfo) {<br class="">
+ // Test GSYM FunctionInfo structs and functionality.<br class="">
+ FunctionInfo invalid;<br class="">
+ EXPECT_FALSE(invalid.isValid());<br class="">
+ EXPECT_FALSE(invalid.hasRichInfo());<br class="">
+ const uint64_t StartAddr = 0x1000;<br class="">
+ const uint64_t EndAddr = 0x1100;<br class="">
+ const uint64_t Size = EndAddr - StartAddr;<br class="">
+ const uint32_t NameOffset = 30;<br class="">
+ FunctionInfo FI(StartAddr, Size, NameOffset);<br class="">
+ EXPECT_TRUE(FI.isValid());<br class="">
+ EXPECT_FALSE(FI.hasRichInfo());<br class="">
+ EXPECT_EQ(FI.startAddress(), StartAddr);<br class="">
+ EXPECT_EQ(FI.endAddress(), EndAddr);<br class="">
+ EXPECT_EQ(FI.size(), Size);<br class="">
+ const uint32_t FileIdx = 1;<br class="">
+ const uint32_t Line = 12;<br class="">
+ FI.Lines.push_back(LineEntry(StartAddr,FileIdx,Line));<br class="">
+ EXPECT_TRUE(FI.hasRichInfo());<br class="">
+ FI.clear();<br class="">
+ EXPECT_FALSE(FI.isValid());<br class="">
+ EXPECT_FALSE(FI.hasRichInfo());<br class="">
+<br class="">
+ FunctionInfo A1(0x1000, 0x100, NameOffset);<br class="">
+ FunctionInfo A2(0x1000, 0x100, NameOffset);<br class="">
+ FunctionInfo B;<br class="">
+ // Check == operator<br class="">
+ EXPECT_EQ(A1, A2);<br class="">
+ // Make sure things are not equal if they only differ by start address.<br class="">
+ B = A2;<br class="">
+ B.setStartAddress(0x2000);<br class="">
+ EXPECT_NE(B, A2);<br class="">
+ // Make sure things are not equal if they only differ by size.<br class="">
+ B = A2;<br class="">
+ B.setSize(0x101);<br class="">
+ EXPECT_NE(B, A2);<br class="">
+ // Make sure things are not equal if they only differ by name.<br class="">
+ B = A2;<br class="">
+ B.Name = 60;<br class="">
+ EXPECT_NE(B, A2);<br class="">
+ // Check < operator.<br class="">
+ // Check less than where address differs.<br class="">
+ B = A2;<br class="">
+ B.setStartAddress(A2.startAddress() + 0x1000);<br class="">
+ EXPECT_LT(A1, B);<br class="">
+ <br class="">
+ // We use the < operator to take a variety of different FunctionInfo<br class="">
+ // structs from a variety of sources: symtab, debug info, runtime info<br class="">
+ // and we sort them and want the sorting to allow us to quickly get the<br class="">
+ // best version of a function info. <br class="">
+ FunctionInfo FISymtab(StartAddr, Size, NameOffset);<br class="">
+ FunctionInfo FIWithLines(StartAddr, Size, NameOffset);<br class="">
+ FIWithLines.Lines.push_back(LineEntry(StartAddr,FileIdx,Line));<br class="">
+ // Test that a FunctionInfo with just a name and size is less than one<br class="">
+ // that has name, size and any number of line table entries<br class="">
+ EXPECT_LT(FISymtab, FIWithLines);<br class="">
+<br class="">
+ FunctionInfo FIWithLinesAndInline = FIWithLines;<br class="">
+ FIWithLinesAndInline.Inline.Ranges.insert(AddressRange(StartAddr, StartAddr + 0x10));<br class="">
+ // Test that a FunctionInfo with name, size, and line entries is less than<br class="">
+ // the same one with valid inline info<br class="">
+ EXPECT_LT(FIWithLines, FIWithLinesAndInline);<br class="">
+<br class="">
+ // Test if we have an entry with lines and one with more lines for the same<br class="">
+ // range, the ones with more lines is greater than the one with less.<br class="">
+ FunctionInfo FIWithMoreLines = FIWithLines;<br class="">
+ FIWithMoreLines.Lines.push_back(LineEntry(StartAddr,FileIdx,Line+5));<br class="">
+ EXPECT_LT(FIWithLines, FIWithMoreLines);<br class="">
+<br class="">
+ // Test that if we have the same number of lines we compare the line entries<br class="">
+ // in the FunctionInfo.Lines vector.<br class="">
+ FunctionInfo FIWithLinesWithHigherAddress = FIWithLines;<br class="">
+ FIWithLinesWithHigherAddress.Lines[0].Addr += 0x10;<br class="">
+ EXPECT_LT(FIWithLines, FIWithLinesWithHigherAddress);<br class="">
+}<br class="">
+<br class="">
+TEST(GSYMTest, TestInlineInfo) {<br class="">
+ // Test InlineInfo structs.<br class="">
+ InlineInfo II;<br class="">
+ EXPECT_FALSE(II.isValid());<br class="">
+ II.Ranges.insert(AddressRange(0x1000,0x2000));<br class="">
+ // Make sure InlineInfo in valid with just an address range since<br class="">
+ // top level InlineInfo objects have ranges with no name, call file<br class="">
+ // or call line<br class="">
+ EXPECT_TRUE(II.isValid());<br class="">
+ // Make sure InlineInfo isn't after being cleared.<br class="">
+ II.clear();<br class="">
+ EXPECT_FALSE(II.isValid());<br class="">
+<br class="">
+ // Create an InlineInfo that contains the following data. The<br class="">
+ // indentation of the address range indicates the parent child<br class="">
+ // relationships of the InlineInfo objects:<br class="">
+ //<br class="">
+ // Variable Range and values<br class="">
+ // =========== ====================================================<br class="">
+ // Root [0x100-0x200) (no name, file, or line)<br class="">
+ // Inline1 [0x150-0x160) Name = 1, File = 1, Line = 11<br class="">
+ // Inline1Sub1 [0x152-0x155) Name = 2, File = 2, Line = 22<br class="">
+ // Inline1Sub2 [0x157-0x158) Name = 3, File = 3, Line = 33<br class="">
+ InlineInfo Root;<br class="">
+ Root.Ranges.insert(AddressRange(0x100,0x200));<br class="">
+ InlineInfo Inline1;<br class="">
+ Inline1.Ranges.insert(AddressRange(0x150,0x160));<br class="">
+ Inline1.Name = 1;<br class="">
+ Inline1.CallFile = 1;<br class="">
+ Inline1.CallLine = 11;<br class="">
+ InlineInfo Inline1Sub1;<br class="">
+ Inline1Sub1.Ranges.insert(AddressRange(0x152, 0x155));<br class="">
+ Inline1Sub1.Name = 2;<br class="">
+ Inline1Sub1.CallFile = 2;<br class="">
+ Inline1Sub1.CallLine = 22;<br class="">
+ InlineInfo Inline1Sub2;<br class="">
+ Inline1Sub2.Ranges.insert(AddressRange(0x157,0x158));<br class="">
+ Inline1Sub2.Name = 3;<br class="">
+ Inline1Sub2.CallFile = 3;<br class="">
+ Inline1Sub2.CallLine = 33;<br class="">
+ Inline1.Children.push_back(Inline1Sub1);<br class="">
+ Inline1.Children.push_back(Inline1Sub2);<br class="">
+ Root.Children.push_back(Inline1);<br class="">
+<br class="">
+ // Make sure an address that is out of range won't match<br class="">
+ EXPECT_FALSE(Root.getInlineStack(0x50));<br class="">
+<br class="">
+ // Verify that we get no inline stacks for addresses out of [0x100-0x200) <br class="">
+ EXPECT_FALSE(Root.getInlineStack(Root.Ranges[0].startAddress()-1));<br class="">
+ EXPECT_FALSE(Root.getInlineStack(Root.Ranges[0].endAddress()));<br class="">
+<br class="">
+ // Verify we get no inline stack entries for addresses that are in<br class="">
+ // [0x100-0x200) but not in [0x150-0x160)<br class="">
+ EXPECT_FALSE(Root.getInlineStack(Inline1.Ranges[0].startAddress()-1));<br class="">
+ EXPECT_FALSE(Root.getInlineStack(Inline1.Ranges[0].endAddress()));<br class="">
+<br class="">
+<br class="">
+ // Verify we get one inline stack entry for addresses that are in<br class="">
+ // [[0x150-0x160)) but not in [0x152-0x155) or [0x157-0x158)<br class="">
+ auto InlineInfos = Root.getInlineStack(Inline1.Ranges[0].startAddress());<br class="">
+ ASSERT_TRUE(InlineInfos);<br class="">
+ ASSERT_EQ(InlineInfos->size(), 1u);<br class="">
+ ASSERT_EQ(*InlineInfos->at(0), Inline1);<br class="">
+ InlineInfos = Root.getInlineStack(Inline1.Ranges[0].endAddress()-1);<br class="">
+ EXPECT_TRUE(InlineInfos);<br class="">
+ ASSERT_EQ(InlineInfos->size(), 1u);<br class="">
+ ASSERT_EQ(*InlineInfos->at(0), Inline1);<br class="">
+<br class="">
+ // Verify we get two inline stack entries for addresses that are in<br class="">
+ // [0x152-0x155)<br class="">
+ InlineInfos = Root.getInlineStack(Inline1Sub1.Ranges[0].startAddress());<br class="">
+ EXPECT_TRUE(InlineInfos);<br class="">
+ ASSERT_EQ(InlineInfos->size(), 2u);<br class="">
+ ASSERT_EQ(*InlineInfos->at(0), Inline1Sub1);<br class="">
+ ASSERT_EQ(*InlineInfos->at(1), Inline1);<br class="">
+ InlineInfos = Root.getInlineStack(Inline1Sub1.Ranges[0].endAddress()-1);<br class="">
+ EXPECT_TRUE(InlineInfos);<br class="">
+ ASSERT_EQ(InlineInfos->size(), 2u);<br class="">
+ ASSERT_EQ(*InlineInfos->at(0), Inline1Sub1);<br class="">
+ ASSERT_EQ(*InlineInfos->at(1), Inline1);<br class="">
+<br class="">
+ // Verify we get two inline stack entries for addresses that are in<br class="">
+ // [0x157-0x158)<br class="">
+ InlineInfos = Root.getInlineStack(Inline1Sub2.Ranges[0].startAddress());<br class="">
+ EXPECT_TRUE(InlineInfos);<br class="">
+ ASSERT_EQ(InlineInfos->size(), 2u);<br class="">
+ ASSERT_EQ(*InlineInfos->at(0), Inline1Sub2);<br class="">
+ ASSERT_EQ(*InlineInfos->at(1), Inline1);<br class="">
+ InlineInfos = Root.getInlineStack(Inline1Sub2.Ranges[0].endAddress()-1);<br class="">
+ EXPECT_TRUE(InlineInfos);<br class="">
+ ASSERT_EQ(InlineInfos->size(), 2u);<br class="">
+ ASSERT_EQ(*InlineInfos->at(0), Inline1Sub2);<br class="">
+ ASSERT_EQ(*InlineInfos->at(1), Inline1);<br class="">
+} <br class="">
+<br class="">
+TEST(GSYMTest, TestLineEntry) {<br class="">
+ // test llvm::gsym::LineEntry structs.<br class="">
+ const uint64_t ValidAddr = 0x1000;<br class="">
+ const uint64_t InvalidFileIdx = 0;<br class="">
+ const uint32_t ValidFileIdx = 1;<br class="">
+ const uint32_t ValidLine = 5;<br class="">
+<br class="">
+ LineEntry Invalid;<br class="">
+ EXPECT_FALSE(Invalid.isValid());<br class="">
+ // Make sure that an entry is invalid if it has a bad file index.<br class="">
+ LineEntry BadFile(ValidAddr, InvalidFileIdx, ValidLine);<br class="">
+ EXPECT_FALSE(BadFile.isValid());<br class="">
+ // Test operators<br class="">
+ LineEntry E1(ValidAddr, ValidFileIdx, ValidLine);<br class="">
+ LineEntry E2(ValidAddr, ValidFileIdx, ValidLine);<br class="">
+ LineEntry DifferentAddr(ValidAddr+1, ValidFileIdx, ValidLine);<br class="">
+ LineEntry DifferentFile(ValidAddr, ValidFileIdx+1, ValidLine);<br class="">
+ LineEntry DifferentLine(ValidAddr, ValidFileIdx, ValidLine+1);<br class="">
+ EXPECT_TRUE(E1.isValid());<br class="">
+ EXPECT_EQ(E1, E2);<br class="">
+ EXPECT_NE(E1, DifferentAddr);<br class="">
+ EXPECT_NE(E1, DifferentFile);<br class="">
+ EXPECT_NE(E1, DifferentLine);<br class="">
+ EXPECT_LT(E1, DifferentAddr);<br class="">
+}<br class="">
+<br class="">
+TEST(GSYMTest, TestRanges) {<br class="">
+ // test llvm::gsym::AddressRange.<br class="">
+ const uint64_t StartAddr = 0x1000;<br class="">
+ const uint64_t EndAddr = 0x2000;<br class="">
+ // Verify constructor and API to ensure it takes start and end address.<br class="">
+ const AddressRange Range(StartAddr, EndAddr);<br class="">
+ EXPECT_EQ(Range.startAddress(), StartAddr);<br class="">
+ EXPECT_EQ(Range.endAddress(), EndAddr);<br class="">
+ EXPECT_EQ(Range.size(), EndAddr-StartAddr);<br class="">
+<br class="">
+ // Verify llvm::gsym::AddressRange::contains().<br class="">
+ EXPECT_FALSE(Range.contains(0));<br class="">
+ EXPECT_FALSE(Range.contains(StartAddr-1));<br class="">
+ EXPECT_TRUE(Range.contains(StartAddr));<br class="">
+ EXPECT_TRUE(Range.contains(EndAddr-1));<br class="">
+ EXPECT_FALSE(Range.contains(EndAddr));<br class="">
+ EXPECT_FALSE(Range.contains(UINT64_MAX));<br class="">
+<br class="">
+ const AddressRange RangeSame(StartAddr, EndAddr);<br class="">
+ const AddressRange RangeDifferentStart(StartAddr+1, EndAddr);<br class="">
+ const AddressRange RangeDifferentEnd(StartAddr, EndAddr+1);<br class="">
+ const AddressRange RangeDifferentStartEnd(StartAddr+1, EndAddr+1);<br class="">
+ // Test == and != with values that are the same<br class="">
+ EXPECT_EQ(Range, RangeSame);<br class="">
+ EXPECT_FALSE(Range != RangeSame);<br class="">
+ // Test == and != with values that are the different<br class="">
+ EXPECT_NE(Range, RangeDifferentStart);<br class="">
+ EXPECT_NE(Range, RangeDifferentEnd);<br class="">
+ EXPECT_NE(Range, RangeDifferentStartEnd);<br class="">
+ EXPECT_FALSE(Range == RangeDifferentStart);<br class="">
+ EXPECT_FALSE(Range == RangeDifferentEnd);<br class="">
+ EXPECT_FALSE(Range == RangeDifferentStartEnd);<br class="">
+<br class="">
+ // Test "bool operator<(const AddressRange &, const AddressRange &)".<br class="">
+ EXPECT_FALSE(Range < RangeSame);<br class="">
+ EXPECT_FALSE(RangeSame < Range);<br class="">
+ EXPECT_LT(Range, RangeDifferentStart);<br class="">
+ EXPECT_LT(Range, RangeDifferentEnd);<br class="">
+ EXPECT_LT(Range, RangeDifferentStartEnd);<br class="">
+ // Test "bool operator<(const AddressRange &, uint64_t)"<br class="">
+ EXPECT_LT(Range, StartAddr + 1);<br class="">
+ // Test "bool operator<(uint64_t, const AddressRange &)"<br class="">
+ EXPECT_LT(StartAddr - 1, Range);<br class="">
+<br class="">
+ // Verify llvm::gsym::AddressRange::isContiguousWith() and<br class="">
+ // llvm::gsym::AddressRange::intersects().<br class="">
+ const AddressRange EndsBeforeRangeStart(0, StartAddr-1);<br class="">
+ const AddressRange EndsAtRangeStart(0, StartAddr);<br class="">
+ const AddressRange OverlapsRangeStart(StartAddr-1, StartAddr+1);<br class="">
+ const AddressRange InsideRange(StartAddr+1, EndAddr-1);<br class="">
+ const AddressRange OverlapsRangeEnd(EndAddr-1, EndAddr+1);<br class="">
+ const AddressRange StartsAtRangeEnd(EndAddr, EndAddr+0x100);<br class="">
+ const AddressRange StartsAfterRangeEnd(EndAddr+1, EndAddr+0x100);<br class="">
+<br class="">
+ EXPECT_FALSE(Range.isContiguousWith(EndsBeforeRangeStart));<br class="">
+ EXPECT_TRUE(Range.isContiguousWith(EndsAtRangeStart));<br class="">
+ EXPECT_TRUE(Range.isContiguousWith(OverlapsRangeStart));<br class="">
+ EXPECT_TRUE(Range.isContiguousWith(InsideRange));<br class="">
+ EXPECT_TRUE(Range.isContiguousWith(OverlapsRangeEnd));<br class="">
+ EXPECT_TRUE(Range.isContiguousWith(StartsAtRangeEnd));<br class="">
+ EXPECT_FALSE(Range.isContiguousWith(StartsAfterRangeEnd));<br class="">
+<br class="">
+ EXPECT_FALSE(Range.intersects(EndsBeforeRangeStart));<br class="">
+ EXPECT_FALSE(Range.intersects(EndsAtRangeStart));<br class="">
+ EXPECT_TRUE(Range.intersects(OverlapsRangeStart));<br class="">
+ EXPECT_TRUE(Range.intersects(InsideRange));<br class="">
+ EXPECT_TRUE(Range.intersects(OverlapsRangeEnd));<br class="">
+ EXPECT_FALSE(Range.intersects(StartsAtRangeEnd));<br class="">
+ EXPECT_FALSE(Range.intersects(StartsAfterRangeEnd));<br class="">
+<br class="">
+ // Test the functions that maintain GSYM address ranges:<br class="">
+ // "bool AddressRange::contains(uint64_t Addr) const;"<br class="">
+ // "void AddressRanges::insert(const AddressRange &R);"<br class="">
+ AddressRanges Ranges;<br class="">
+ Ranges.insert(AddressRange(0x1000, 0x2000));<br class="">
+ Ranges.insert(AddressRange(0x2000, 0x3000));<br class="">
+ Ranges.insert(AddressRange(0x4000, 0x5000));<br class="">
+<br class="">
+ EXPECT_FALSE(Ranges.contains(0));<br class="">
+ EXPECT_FALSE(Ranges.contains(0x1000-1));<br class="">
+ EXPECT_TRUE(Ranges.contains(0x1000));<br class="">
+ EXPECT_TRUE(Ranges.contains(0x2000));<br class="">
+ EXPECT_TRUE(Ranges.contains(0x4000));<br class="">
+ EXPECT_TRUE(Ranges.contains(0x2000-1));<br class="">
+ EXPECT_TRUE(Ranges.contains(0x3000-1));<br class="">
+ EXPECT_FALSE(Ranges.contains(0x3000+1));<br class="">
+ EXPECT_TRUE(Ranges.contains(0x5000-1));<br class="">
+ EXPECT_FALSE(Ranges.contains(0x5000+1));<br class="">
+ EXPECT_FALSE(Ranges.contains(UINT64_MAX));<br class="">
+<br class="">
+ // Verify that intersecting ranges get combined<br class="">
+ Ranges.clear();<br class="">
+ Ranges.insert(AddressRange(0x1100, 0x1F00));<br class="">
+ // Verify a wholy contained range that is added doesn't do anything.<br class="">
+ Ranges.insert(AddressRange(0x1500, 0x1F00));<br class="">
+ EXPECT_EQ(Ranges.size(), 1u);<br class="">
+ EXPECT_EQ(Ranges[0], AddressRange(0x1100, 0x1F00));<br class="">
+<br class="">
+ // Verify a range that starts before and intersects gets combined.<br class="">
+ Ranges.insert(AddressRange(0x1000, Ranges[0].startAddress()+1));<br class="">
+ EXPECT_EQ(Ranges.size(), 1u);<br class="">
+ EXPECT_EQ(Ranges[0], AddressRange(0x1000, 0x1F00));<br class="">
+<br class="">
+ // Verify a range that starts inside and extends ranges gets combined.<br class="">
+ Ranges.insert(AddressRange(Ranges[0].endAddress()-1, 0x2000));<br class="">
+ EXPECT_EQ(Ranges.size(), 1u);<br class="">
+ EXPECT_EQ(Ranges[0], AddressRange(0x1000, 0x2000));<br class="">
+<br class="">
+ // Verify that adjacent ranges don't get combined<br class="">
+ Ranges.insert(AddressRange(0x2000, 0x3000));<br class="">
+ EXPECT_EQ(Ranges.size(), 2u);<br class="">
+ EXPECT_EQ(Ranges[0], AddressRange(0x1000, 0x2000));<br class="">
+ EXPECT_EQ(Ranges[1], AddressRange(0x2000, 0x3000));<br class="">
+ // Verify if we add an address range that intersects two ranges<br class="">
+ // that they get combined<br class="">
+ Ranges.insert(AddressRange(Ranges[0].endAddress()-1, <br class="">
+ Ranges[1].startAddress()+1));<br class="">
+ EXPECT_EQ(Ranges.size(), 1u);<br class="">
+ EXPECT_EQ(Ranges[0], AddressRange(0x1000, 0x3000));<br class="">
+<br class="">
+<br class="">
+}<br class="">
+<br class="">
+TEST(GSYMTest, TestStringTable) {<br class="">
+ StringTable StrTab(StringRef("\0Hello\0World\0", 13));<br class="">
+ // Test extracting strings from a string table.<br class="">
+ EXPECT_EQ(StrTab.getString(0), "");<br class="">
+ EXPECT_EQ(StrTab.getString(1), "Hello");<br class="">
+ EXPECT_EQ(StrTab.getString(7), "World");<br class="">
+ EXPECT_EQ(StrTab.getString(8), "orld");<br class="">
+ // Test pointing to last NULL terminator gets empty string.<br class="">
+ EXPECT_EQ(StrTab.getString(12), "");<br class="">
+ // Test pointing to past end gets empty string.<br class="">
+ EXPECT_EQ(StrTab.getString(13), "");<br class="">
+}<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>