[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/include/lldb/Core/MappedHash.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/MappedHash.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/MappedHash.h (original)
+++ lldb/trunk/include/lldb/Core/MappedHash.h Tue Sep 6 15:57:50 2016
@@ -25,535 +25,460 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
-class MappedHash
-{
+class MappedHash {
public:
- enum HashFunctionType
- {
- eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections
- };
+ enum HashFunctionType {
+ eHashFunctionDJB = 0u // Daniel J Bernstein hash function that is also used
+ // by the ELF GNU_HASH sections
+ };
+
+ static uint32_t HashStringUsingDJB(const char *s) {
+ uint32_t h = 5381;
+
+ for (unsigned char c = *s; c; c = *++s)
+ h = ((h << 5) + h) + c;
+
+ return h;
+ }
+
+ static uint32_t HashString(uint32_t hash_function, const char *s) {
+ if (!s)
+ return 0;
+
+ switch (hash_function) {
+ case MappedHash::eHashFunctionDJB:
+ return HashStringUsingDJB(s);
- static uint32_t
- HashStringUsingDJB (const char *s)
- {
- uint32_t h = 5381;
-
- for (unsigned char c = *s; c; c = *++s)
- h = ((h << 5) + h) + c;
-
- return h;
- }
-
- static uint32_t
- HashString (uint32_t hash_function, const char *s)
- {
- if (!s)
- return 0;
-
- switch (hash_function)
- {
- case MappedHash::eHashFunctionDJB:
- return HashStringUsingDJB (s);
-
- default:
- break;
- }
- assert (!"Invalid hash function index");
- return 0;
+ default:
+ break;
+ }
+ assert(!"Invalid hash function index");
+ return 0;
+ }
+
+ static const uint32_t HASH_MAGIC = 0x48415348u;
+ static const uint32_t HASH_CIGAM = 0x48534148u;
+
+ template <typename T> struct Header {
+ typedef T HeaderData;
+
+ uint32_t
+ magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection
+ uint16_t version; // Version number
+ uint16_t hash_function; // The hash function enumeration that was used
+ uint32_t bucket_count; // The number of buckets in this hash table
+ uint32_t hashes_count; // The total number of unique hash values and hash
+ // data offsets in this table
+ uint32_t header_data_len; // The size in bytes of the "header_data" template
+ // member below
+ HeaderData header_data; //
+
+ Header()
+ : magic(HASH_MAGIC), version(1), hash_function(eHashFunctionDJB),
+ bucket_count(0), hashes_count(0), header_data_len(sizeof(T)),
+ header_data() {}
+
+ virtual ~Header() = default;
+
+ size_t GetByteSize() const {
+ return sizeof(magic) + sizeof(version) + sizeof(hash_function) +
+ sizeof(bucket_count) + sizeof(hashes_count) +
+ sizeof(header_data_len) + header_data_len;
}
- static const uint32_t HASH_MAGIC = 0x48415348u;
- static const uint32_t HASH_CIGAM = 0x48534148u;
-
- template <typename T>
- struct Header
- {
- typedef T HeaderData;
-
- uint32_t magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection
- uint16_t version; // Version number
- uint16_t hash_function; // The hash function enumeration that was used
- uint32_t bucket_count; // The number of buckets in this hash table
- uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table
- uint32_t header_data_len; // The size in bytes of the "header_data" template member below
- HeaderData header_data; //
-
- Header () :
- magic (HASH_MAGIC),
- version (1),
- hash_function (eHashFunctionDJB),
- bucket_count (0),
- hashes_count (0),
- header_data_len (sizeof(T)),
- header_data ()
- {
- }
-
- virtual
- ~Header() = default;
-
- size_t
- GetByteSize() const
- {
- return sizeof(magic) +
- sizeof(version) +
- sizeof(hash_function) +
- sizeof(bucket_count) +
- sizeof(hashes_count) +
- sizeof(header_data_len) +
- header_data_len;
- }
-
- virtual size_t
- GetByteSize (const HeaderData &header_data) = 0;
-
- void
- SetHeaderDataByteSize (uint32_t header_data_byte_size)
- {
- header_data_len = header_data_byte_size;
- }
+ virtual size_t GetByteSize(const HeaderData &header_data) = 0;
- void
- Dump (lldb_private::Stream &s)
- {
- s.Printf ("header.magic = 0x%8.8x\n", magic);
- s.Printf ("header.version = 0x%4.4x\n", version);
- s.Printf ("header.hash_function = 0x%4.4x\n", hash_function);
- s.Printf ("header.bucket_count = 0x%8.8x %u\n", bucket_count, bucket_count);
- s.Printf ("header.hashes_count = 0x%8.8x %u\n", hashes_count, hashes_count);
- s.Printf ("header.header_data_len = 0x%8.8x %u\n", header_data_len, header_data_len);
- }
-
- virtual lldb::offset_t
- Read (lldb_private::DataExtractor &data, lldb::offset_t offset)
- {
- if (data.ValidOffsetForDataOfSize (offset,
- sizeof (magic) +
- sizeof (version) +
- sizeof (hash_function) +
- sizeof (bucket_count) +
- sizeof (hashes_count) +
- sizeof (header_data_len)))
- {
- magic = data.GetU32 (&offset);
- if (magic != HASH_MAGIC)
- {
- if (magic == HASH_CIGAM)
- {
- switch (data.GetByteOrder())
- {
- case lldb::eByteOrderBig:
- data.SetByteOrder(lldb::eByteOrderLittle);
- break;
- case lldb::eByteOrderLittle:
- data.SetByteOrder(lldb::eByteOrderBig);
- break;
- default:
- return LLDB_INVALID_OFFSET;
- }
- }
- else
- {
- // Magic bytes didn't match
- version = 0;
- return LLDB_INVALID_OFFSET;
- }
- }
-
- version = data.GetU16 (&offset);
- if (version != 1)
- {
- // Unsupported version
- return LLDB_INVALID_OFFSET;
- }
- hash_function = data.GetU16 (&offset);
- if (hash_function == 4)
- hash_function = 0; // Deal with pre-release version of this table...
- bucket_count = data.GetU32 (&offset);
- hashes_count = data.GetU32 (&offset);
- header_data_len = data.GetU32 (&offset);
- return offset;
+ void SetHeaderDataByteSize(uint32_t header_data_byte_size) {
+ header_data_len = header_data_byte_size;
+ }
+
+ void Dump(lldb_private::Stream &s) {
+ s.Printf("header.magic = 0x%8.8x\n", magic);
+ s.Printf("header.version = 0x%4.4x\n", version);
+ s.Printf("header.hash_function = 0x%4.4x\n", hash_function);
+ s.Printf("header.bucket_count = 0x%8.8x %u\n", bucket_count,
+ bucket_count);
+ s.Printf("header.hashes_count = 0x%8.8x %u\n", hashes_count,
+ hashes_count);
+ s.Printf("header.header_data_len = 0x%8.8x %u\n", header_data_len,
+ header_data_len);
+ }
+
+ virtual lldb::offset_t Read(lldb_private::DataExtractor &data,
+ lldb::offset_t offset) {
+ if (data.ValidOffsetForDataOfSize(
+ offset, sizeof(magic) + sizeof(version) + sizeof(hash_function) +
+ sizeof(bucket_count) + sizeof(hashes_count) +
+ sizeof(header_data_len))) {
+ magic = data.GetU32(&offset);
+ if (magic != HASH_MAGIC) {
+ if (magic == HASH_CIGAM) {
+ switch (data.GetByteOrder()) {
+ case lldb::eByteOrderBig:
+ data.SetByteOrder(lldb::eByteOrderLittle);
+ break;
+ case lldb::eByteOrderLittle:
+ data.SetByteOrder(lldb::eByteOrderBig);
+ break;
+ default:
+ return LLDB_INVALID_OFFSET;
}
+ } else {
+ // Magic bytes didn't match
+ version = 0;
return LLDB_INVALID_OFFSET;
- }
-//
-// // Returns a buffer that contains a serialized version of this table
-// // that must be freed with free().
-// virtual void *
-// Write (int fd);
- };
-
- template <typename __KeyType, class __HeaderDataType, class __ValueType>
- class ExportTable
- {
- public:
- typedef __HeaderDataType HeaderDataType;
- typedef Header<HeaderDataType> HeaderType;
- typedef __KeyType KeyType;
- typedef __ValueType ValueType;
-
- struct Entry
- {
- uint32_t hash;
- KeyType key;
- ValueType value;
- };
-
- typedef std::vector<ValueType> ValueArrayType;
-
- typedef std::map<KeyType, ValueArrayType> HashData;
- // Map a name hash to one or more name infos
- typedef std::map<uint32_t, HashData> HashToHashData;
-
- virtual KeyType
- GetKeyForStringType (const char *cstr) const = 0;
-
- virtual size_t
- GetByteSize (const HashData &key_to_key_values) = 0;
-
- virtual bool
- WriteHashData (const HashData &hash_data,
- lldb_private::Stream &ostrm) = 0;
-//
- void
- AddEntry (const char *cstr, const ValueType &value)
- {
- Entry entry;
- entry.hash = MappedHash::HashString (eHashFunctionDJB, cstr);
- entry.key = GetKeyForStringType (cstr);
- entry.value = value;
- m_entries.push_back (entry);
+ }
}
- void
- Save (const HeaderDataType &header_data,
- lldb_private::Stream &ostrm)
- {
- if (m_entries.empty())
- return;
-
- const uint32_t num_entries = m_entries.size();
- uint32_t i = 0;
-
- HeaderType header;
-
- header.magic = HASH_MAGIC;
- header.version = 1;
- header.hash_function = eHashFunctionDJB;
- header.bucket_count = 0;
- header.hashes_count = 0;
- header.prologue_length = header_data.GetByteSize();
-
- // We need to figure out the number of unique hashes first before we can
- // calculate the number of buckets we want to use.
- typedef std::vector<uint32_t> hash_coll;
- hash_coll unique_hashes;
- unique_hashes.resize (num_entries);
- for (i=0; i<num_entries; ++i)
- unique_hashes[i] = m_entries[i].hash;
- std::sort (unique_hashes.begin(), unique_hashes.end());
- hash_coll::iterator pos = std::unique (unique_hashes.begin(), unique_hashes.end());
- const size_t num_unique_hashes = std::distance (unique_hashes.begin(), pos);
-
- if (num_unique_hashes > 1024)
- header.bucket_count = num_unique_hashes/4;
- else if (num_unique_hashes > 16)
- header.bucket_count = num_unique_hashes/2;
- else
- header.bucket_count = num_unique_hashes;
- if (header.bucket_count == 0)
- header.bucket_count = 1;
-
- std::vector<HashToHashData> hash_buckets;
- std::vector<uint32_t> hash_indexes (header.bucket_count, 0);
- std::vector<uint32_t> hash_values;
- std::vector<uint32_t> hash_offsets;
- hash_buckets.resize (header.bucket_count);
- uint32_t bucket_entry_empties = 0;
- //StreamString hash_file_data(Stream::eBinary, dwarf->GetObjectFile()->GetAddressByteSize(), dwarf->GetObjectFile()->GetByteSize());
-
- // Push all of the hashes into their buckets and create all bucket
- // entries all populated with data.
- for (i=0; i<num_entries; ++i)
- {
- const uint32_t hash = m_entries[i].hash;
- const uint32_t bucket_idx = hash % header.bucket_count;
- const uint32_t strp_offset = m_entries[i].str_offset;
- const uint32_t die_offset = m_entries[i].die_offset;
- hash_buckets[bucket_idx][hash][strp_offset].push_back(die_offset);
- }
-
- // Now for each bucket we write the bucket value which is the
- // number of hashes and the hash index encoded into a single
- // 32 bit unsigned integer.
- for (i=0; i<header.bucket_count; ++i)
- {
- HashToHashData &bucket_entry = hash_buckets[i];
-
- if (bucket_entry.empty())
- {
- // Empty bucket
- ++bucket_entry_empties;
- hash_indexes[i] = UINT32_MAX;
- }
- else
- {
- const uint32_t hash_value_index = hash_values.size();
- uint32_t hash_count = 0;
- typename HashToHashData::const_iterator pos, end = bucket_entry.end();
- for (pos = bucket_entry.begin(); pos != end; ++pos)
- {
- hash_values.push_back (pos->first);
- hash_offsets.push_back (GetByteSize (pos->second));
- ++hash_count;
- }
-
- hash_indexes[i] = hash_value_index;
- }
- }
- header.hashes_count = hash_values.size();
-
- // Write the header out now that we have the hash_count
- header.Write (ostrm);
-
- // Now for each bucket we write the start index of the hashes
- // for the current bucket, or UINT32_MAX if the bucket is empty
- for (i=0; i<header.bucket_count; ++i)
- {
- ostrm.PutHex32(hash_indexes[i]);
- }
-
- // Now we need to write out all of the hash values
- for (i=0; i<header.hashes_count; ++i)
- {
- ostrm.PutHex32(hash_values[i]);
- }
+ version = data.GetU16(&offset);
+ if (version != 1) {
+ // Unsupported version
+ return LLDB_INVALID_OFFSET;
+ }
+ hash_function = data.GetU16(&offset);
+ if (hash_function == 4)
+ hash_function = 0; // Deal with pre-release version of this table...
+ bucket_count = data.GetU32(&offset);
+ hashes_count = data.GetU32(&offset);
+ header_data_len = data.GetU32(&offset);
+ return offset;
+ }
+ return LLDB_INVALID_OFFSET;
+ }
+ //
+ // // Returns a buffer that contains a serialized version of this
+ // table
+ // // that must be freed with free().
+ // virtual void *
+ // Write (int fd);
+ };
+
+ template <typename __KeyType, class __HeaderDataType, class __ValueType>
+ class ExportTable {
+ public:
+ typedef __HeaderDataType HeaderDataType;
+ typedef Header<HeaderDataType> HeaderType;
+ typedef __KeyType KeyType;
+ typedef __ValueType ValueType;
+
+ struct Entry {
+ uint32_t hash;
+ KeyType key;
+ ValueType value;
+ };
- // Now we need to write out all of the hash data offsets,
- // there is an offset for each hash in the hashes array
- // that was written out above
- for (i=0; i<header.hashes_count; ++i)
- {
- ostrm.PutHex32(hash_offsets[i]);
- }
+ typedef std::vector<ValueType> ValueArrayType;
- // Now we write the data for each hash and verify we got the offset
- // correct above...
- for (i=0; i<header.bucket_count; ++i)
- {
- HashToHashData &bucket_entry = hash_buckets[i];
-
- typename HashToHashData::const_iterator pos, end = bucket_entry.end();
- for (pos = bucket_entry.begin(); pos != end; ++pos)
- {
- if (!bucket_entry.empty())
- {
- WriteHashData (pos->second);
- }
- }
- }
+ typedef std::map<KeyType, ValueArrayType> HashData;
+ // Map a name hash to one or more name infos
+ typedef std::map<uint32_t, HashData> HashToHashData;
+
+ virtual KeyType GetKeyForStringType(const char *cstr) const = 0;
+
+ virtual size_t GetByteSize(const HashData &key_to_key_values) = 0;
+
+ virtual bool WriteHashData(const HashData &hash_data,
+ lldb_private::Stream &ostrm) = 0;
+ //
+ void AddEntry(const char *cstr, const ValueType &value) {
+ Entry entry;
+ entry.hash = MappedHash::HashString(eHashFunctionDJB, cstr);
+ entry.key = GetKeyForStringType(cstr);
+ entry.value = value;
+ m_entries.push_back(entry);
+ }
+
+ void Save(const HeaderDataType &header_data, lldb_private::Stream &ostrm) {
+ if (m_entries.empty())
+ return;
+
+ const uint32_t num_entries = m_entries.size();
+ uint32_t i = 0;
+
+ HeaderType header;
+
+ header.magic = HASH_MAGIC;
+ header.version = 1;
+ header.hash_function = eHashFunctionDJB;
+ header.bucket_count = 0;
+ header.hashes_count = 0;
+ header.prologue_length = header_data.GetByteSize();
+
+ // We need to figure out the number of unique hashes first before we can
+ // calculate the number of buckets we want to use.
+ typedef std::vector<uint32_t> hash_coll;
+ hash_coll unique_hashes;
+ unique_hashes.resize(num_entries);
+ for (i = 0; i < num_entries; ++i)
+ unique_hashes[i] = m_entries[i].hash;
+ std::sort(unique_hashes.begin(), unique_hashes.end());
+ hash_coll::iterator pos =
+ std::unique(unique_hashes.begin(), unique_hashes.end());
+ const size_t num_unique_hashes =
+ std::distance(unique_hashes.begin(), pos);
+
+ if (num_unique_hashes > 1024)
+ header.bucket_count = num_unique_hashes / 4;
+ else if (num_unique_hashes > 16)
+ header.bucket_count = num_unique_hashes / 2;
+ else
+ header.bucket_count = num_unique_hashes;
+ if (header.bucket_count == 0)
+ header.bucket_count = 1;
+
+ std::vector<HashToHashData> hash_buckets;
+ std::vector<uint32_t> hash_indexes(header.bucket_count, 0);
+ std::vector<uint32_t> hash_values;
+ std::vector<uint32_t> hash_offsets;
+ hash_buckets.resize(header.bucket_count);
+ uint32_t bucket_entry_empties = 0;
+ // StreamString hash_file_data(Stream::eBinary,
+ // dwarf->GetObjectFile()->GetAddressByteSize(),
+ // dwarf->GetObjectFile()->GetByteSize());
+
+ // Push all of the hashes into their buckets and create all bucket
+ // entries all populated with data.
+ for (i = 0; i < num_entries; ++i) {
+ const uint32_t hash = m_entries[i].hash;
+ const uint32_t bucket_idx = hash % header.bucket_count;
+ const uint32_t strp_offset = m_entries[i].str_offset;
+ const uint32_t die_offset = m_entries[i].die_offset;
+ hash_buckets[bucket_idx][hash][strp_offset].push_back(die_offset);
+ }
+
+ // Now for each bucket we write the bucket value which is the
+ // number of hashes and the hash index encoded into a single
+ // 32 bit unsigned integer.
+ for (i = 0; i < header.bucket_count; ++i) {
+ HashToHashData &bucket_entry = hash_buckets[i];
+
+ if (bucket_entry.empty()) {
+ // Empty bucket
+ ++bucket_entry_empties;
+ hash_indexes[i] = UINT32_MAX;
+ } else {
+ const uint32_t hash_value_index = hash_values.size();
+ uint32_t hash_count = 0;
+ typename HashToHashData::const_iterator pos, end = bucket_entry.end();
+ for (pos = bucket_entry.begin(); pos != end; ++pos) {
+ hash_values.push_back(pos->first);
+ hash_offsets.push_back(GetByteSize(pos->second));
+ ++hash_count;
+ }
+
+ hash_indexes[i] = hash_value_index;
+ }
+ }
+ header.hashes_count = hash_values.size();
+
+ // Write the header out now that we have the hash_count
+ header.Write(ostrm);
+
+ // Now for each bucket we write the start index of the hashes
+ // for the current bucket, or UINT32_MAX if the bucket is empty
+ for (i = 0; i < header.bucket_count; ++i) {
+ ostrm.PutHex32(hash_indexes[i]);
+ }
+
+ // Now we need to write out all of the hash values
+ for (i = 0; i < header.hashes_count; ++i) {
+ ostrm.PutHex32(hash_values[i]);
+ }
+
+ // Now we need to write out all of the hash data offsets,
+ // there is an offset for each hash in the hashes array
+ // that was written out above
+ for (i = 0; i < header.hashes_count; ++i) {
+ ostrm.PutHex32(hash_offsets[i]);
+ }
+
+ // Now we write the data for each hash and verify we got the offset
+ // correct above...
+ for (i = 0; i < header.bucket_count; ++i) {
+ HashToHashData &bucket_entry = hash_buckets[i];
+
+ typename HashToHashData::const_iterator pos, end = bucket_entry.end();
+ for (pos = bucket_entry.begin(); pos != end; ++pos) {
+ if (!bucket_entry.empty()) {
+ WriteHashData(pos->second);
+ }
}
+ }
+ }
- protected:
- typedef std::vector<Entry> collection;
- collection m_entries;
+ protected:
+ typedef std::vector<Entry> collection;
+ collection m_entries;
+ };
+
+ // A class for reading and using a saved hash table from a block of data
+ // in memory
+ template <typename __KeyType, class __HeaderType, class __HashData>
+ class MemoryTable {
+ public:
+ typedef __HeaderType HeaderType;
+ typedef __KeyType KeyType;
+ typedef __HashData HashData;
+
+ enum Result {
+ eResultKeyMatch = 0u, // The entry was found, key matched and "pair" was
+ // filled in successfully
+ eResultKeyMismatch =
+ 1u, // Bucket hash data collision, but key didn't match
+ eResultEndOfHashData = 2u, // The chain of items for this hash data in
+ // this bucket is terminated, search no more
+ eResultError = 3u // Error parsing the hash data, abort
};
- // A class for reading and using a saved hash table from a block of data
- // in memory
- template <typename __KeyType, class __HeaderType, class __HashData>
- class MemoryTable
- {
- public:
- typedef __HeaderType HeaderType;
- typedef __KeyType KeyType;
- typedef __HashData HashData;
-
- enum Result
- {
- eResultKeyMatch = 0u, // The entry was found, key matched and "pair" was filled in successfully
- eResultKeyMismatch = 1u, // Bucket hash data collision, but key didn't match
- eResultEndOfHashData = 2u, // The chain of items for this hash data in this bucket is terminated, search no more
- eResultError = 3u // Error parsing the hash data, abort
- };
-
- struct Pair
- {
- KeyType key;
- HashData value;
- };
-
- MemoryTable (lldb_private::DataExtractor &data) :
- m_header (),
- m_hash_indexes (nullptr),
- m_hash_values (nullptr),
- m_hash_offsets (nullptr)
- {
- lldb::offset_t offset = m_header.Read (data, 0);
- if (offset != LLDB_INVALID_OFFSET && IsValid ())
- {
- m_hash_indexes = (const uint32_t *)data.GetData (&offset, m_header.bucket_count * sizeof(uint32_t));
- m_hash_values = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
- m_hash_offsets = (const uint32_t *)data.GetData (&offset, m_header.hashes_count * sizeof(uint32_t));
- }
- }
+ struct Pair {
+ KeyType key;
+ HashData value;
+ };
- virtual
- ~MemoryTable() = default;
+ MemoryTable(lldb_private::DataExtractor &data)
+ : m_header(), m_hash_indexes(nullptr), m_hash_values(nullptr),
+ m_hash_offsets(nullptr) {
+ lldb::offset_t offset = m_header.Read(data, 0);
+ if (offset != LLDB_INVALID_OFFSET && IsValid()) {
+ m_hash_indexes = (const uint32_t *)data.GetData(
+ &offset, m_header.bucket_count * sizeof(uint32_t));
+ m_hash_values = (const uint32_t *)data.GetData(
+ &offset, m_header.hashes_count * sizeof(uint32_t));
+ m_hash_offsets = (const uint32_t *)data.GetData(
+ &offset, m_header.hashes_count * sizeof(uint32_t));
+ }
+ }
- bool
- IsValid () const
- {
- return m_header.version == 1 &&
- m_header.hash_function == eHashFunctionDJB &&
- m_header.bucket_count > 0 &&
- m_header.hashes_count > 0;
- }
-
- uint32_t
- GetHashIndex (uint32_t bucket_idx) const
- {
- if (m_hash_indexes && bucket_idx < m_header.bucket_count)
- return m_hash_indexes[bucket_idx];
- return UINT32_MAX;
- }
-
- uint32_t
- GetHashValue (uint32_t hash_idx) const
- {
- if (m_hash_values && hash_idx < m_header.hashes_count)
- return m_hash_values[hash_idx];
- return UINT32_MAX;
- }
-
- uint32_t
- GetHashDataOffset (uint32_t hash_idx) const
- {
- if (m_hash_offsets && hash_idx < m_header.hashes_count)
- return m_hash_offsets[hash_idx];
- return UINT32_MAX;
- }
-
- bool
- Find (const char *name, Pair &pair) const
- {
- if (!name || !name[0])
- return false;
-
- if (IsValid ())
- {
- const uint32_t bucket_count = m_header.bucket_count;
- const uint32_t hash_count = m_header.hashes_count;
- const uint32_t hash_value = MappedHash::HashString (m_header.hash_function, name);
- const uint32_t bucket_idx = hash_value % bucket_count;
- uint32_t hash_idx = GetHashIndex (bucket_idx);
- if (hash_idx < hash_count)
- {
- for (; hash_idx < hash_count; ++hash_idx)
- {
- const uint32_t curr_hash_value = GetHashValue (hash_idx);
- if (curr_hash_value == hash_value)
- {
- lldb::offset_t hash_data_offset = GetHashDataOffset (hash_idx);
- while (hash_data_offset != UINT32_MAX)
- {
- const lldb::offset_t prev_hash_data_offset = hash_data_offset;
- Result hash_result = GetHashDataForName (name, &hash_data_offset, pair);
- // Check the result of getting our hash data
- switch (hash_result)
- {
- case eResultKeyMatch:
- return true;
-
- case eResultKeyMismatch:
- if (prev_hash_data_offset == hash_data_offset)
- return false;
- break;
-
- case eResultEndOfHashData:
- // The last HashData for this key has been reached, stop searching
- return false;
- case eResultError:
- // Error parsing the hash data, abort
- return false;
- }
- }
- }
- if ((curr_hash_value % bucket_count) != bucket_idx)
- break;
- }
- }
- }
- return false;
- }
+ virtual ~MemoryTable() = default;
- // This method must be implemented in any subclasses.
- // The KeyType is user specified and must somehow result in a string
- // value. For example, the KeyType might be a string offset in a string
- // table and subclasses can store their string table as a member of the
- // subclass and return a valie "const char *" given a "key". The value
- // could also be a C string pointer, in which case just returning "key"
- // will suffice.
- virtual const char *
- GetStringForKeyType (KeyType key) const = 0;
-
- virtual bool
- ReadHashData (uint32_t hash_data_offset,
- HashData &hash_data) const = 0;
-
- // This method must be implemented in any subclasses and it must try to
- // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr"
- // parameter. This offset should be updated as bytes are consumed and
- // a value "Result" enum should be returned. If the "name" matches the
- // full name for the "pair.key" (which must be filled in by this call),
- // then the HashData in the pair ("pair.value") should be extracted and
- // filled in and "eResultKeyMatch" should be returned. If "name" doesn't
- // match this string for the key, then "eResultKeyMismatch" should be
- // returned and all data for the current HashData must be consumed or
- // skipped and the "hash_data_offset_ptr" offset needs to be updated to
- // point to the next HashData. If the end of the HashData objects for
- // a given hash value have been reached, then "eResultEndOfHashData"
- // should be returned. If anything else goes wrong during parsing,
- // return "eResultError" and the corresponding "Find()" function will
- // be canceled and return false.
- virtual Result
- GetHashDataForName (const char *name,
- lldb::offset_t* hash_data_offset_ptr,
- Pair &pair) const = 0;
-
- const HeaderType &
- GetHeader()
- {
- return m_header;
- }
+ bool IsValid() const {
+ return m_header.version == 1 &&
+ m_header.hash_function == eHashFunctionDJB &&
+ m_header.bucket_count > 0 && m_header.hashes_count > 0;
+ }
+
+ uint32_t GetHashIndex(uint32_t bucket_idx) const {
+ if (m_hash_indexes && bucket_idx < m_header.bucket_count)
+ return m_hash_indexes[bucket_idx];
+ return UINT32_MAX;
+ }
- void
- ForEach (std::function <bool(const HashData &hash_data)> const &callback) const
- {
- const size_t num_hash_offsets = m_header.hashes_count;
- for (size_t i=0; i<num_hash_offsets; ++i)
- {
- uint32_t hash_data_offset = GetHashDataOffset (i);
- if (hash_data_offset != UINT32_MAX)
- {
- HashData hash_data;
- if (ReadHashData (hash_data_offset, hash_data))
- {
- // If the callback returns false, then we are done and should stop
- if (callback(hash_data) == false)
- return;
- }
+ uint32_t GetHashValue(uint32_t hash_idx) const {
+ if (m_hash_values && hash_idx < m_header.hashes_count)
+ return m_hash_values[hash_idx];
+ return UINT32_MAX;
+ }
+
+ uint32_t GetHashDataOffset(uint32_t hash_idx) const {
+ if (m_hash_offsets && hash_idx < m_header.hashes_count)
+ return m_hash_offsets[hash_idx];
+ return UINT32_MAX;
+ }
+
+ bool Find(const char *name, Pair &pair) const {
+ if (!name || !name[0])
+ return false;
+
+ if (IsValid()) {
+ const uint32_t bucket_count = m_header.bucket_count;
+ const uint32_t hash_count = m_header.hashes_count;
+ const uint32_t hash_value =
+ MappedHash::HashString(m_header.hash_function, name);
+ const uint32_t bucket_idx = hash_value % bucket_count;
+ uint32_t hash_idx = GetHashIndex(bucket_idx);
+ if (hash_idx < hash_count) {
+ for (; hash_idx < hash_count; ++hash_idx) {
+ const uint32_t curr_hash_value = GetHashValue(hash_idx);
+ if (curr_hash_value == hash_value) {
+ lldb::offset_t hash_data_offset = GetHashDataOffset(hash_idx);
+ while (hash_data_offset != UINT32_MAX) {
+ const lldb::offset_t prev_hash_data_offset = hash_data_offset;
+ Result hash_result =
+ GetHashDataForName(name, &hash_data_offset, pair);
+ // Check the result of getting our hash data
+ switch (hash_result) {
+ case eResultKeyMatch:
+ return true;
+
+ case eResultKeyMismatch:
+ if (prev_hash_data_offset == hash_data_offset)
+ return false;
+ break;
+
+ case eResultEndOfHashData:
+ // The last HashData for this key has been reached, stop
+ // searching
+ return false;
+ case eResultError:
+ // Error parsing the hash data, abort
+ return false;
}
+ }
}
+ if ((curr_hash_value % bucket_count) != bucket_idx)
+ break;
+ }
}
+ }
+ return false;
+ }
- protected:
- // Implementation agnostic information
- HeaderType m_header;
- const uint32_t *m_hash_indexes;
- const uint32_t *m_hash_values;
- const uint32_t *m_hash_offsets;
- };
+ // This method must be implemented in any subclasses.
+ // The KeyType is user specified and must somehow result in a string
+ // value. For example, the KeyType might be a string offset in a string
+ // table and subclasses can store their string table as a member of the
+ // subclass and return a valie "const char *" given a "key". The value
+ // could also be a C string pointer, in which case just returning "key"
+ // will suffice.
+ virtual const char *GetStringForKeyType(KeyType key) const = 0;
+
+ virtual bool ReadHashData(uint32_t hash_data_offset,
+ HashData &hash_data) const = 0;
+
+ // This method must be implemented in any subclasses and it must try to
+ // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr"
+ // parameter. This offset should be updated as bytes are consumed and
+ // a value "Result" enum should be returned. If the "name" matches the
+ // full name for the "pair.key" (which must be filled in by this call),
+ // then the HashData in the pair ("pair.value") should be extracted and
+ // filled in and "eResultKeyMatch" should be returned. If "name" doesn't
+ // match this string for the key, then "eResultKeyMismatch" should be
+ // returned and all data for the current HashData must be consumed or
+ // skipped and the "hash_data_offset_ptr" offset needs to be updated to
+ // point to the next HashData. If the end of the HashData objects for
+ // a given hash value have been reached, then "eResultEndOfHashData"
+ // should be returned. If anything else goes wrong during parsing,
+ // return "eResultError" and the corresponding "Find()" function will
+ // be canceled and return false.
+ virtual Result GetHashDataForName(const char *name,
+ lldb::offset_t *hash_data_offset_ptr,
+ Pair &pair) const = 0;
+
+ const HeaderType &GetHeader() { return m_header; }
+
+ void ForEach(
+ std::function<bool(const HashData &hash_data)> const &callback) const {
+ const size_t num_hash_offsets = m_header.hashes_count;
+ for (size_t i = 0; i < num_hash_offsets; ++i) {
+ uint32_t hash_data_offset = GetHashDataOffset(i);
+ if (hash_data_offset != UINT32_MAX) {
+ HashData hash_data;
+ if (ReadHashData(hash_data_offset, hash_data)) {
+ // If the callback returns false, then we are done and should stop
+ if (callback(hash_data) == false)
+ return;
+ }
+ }
+ }
+ }
+
+ protected:
+ // Implementation agnostic information
+ HeaderType m_header;
+ const uint32_t *m_hash_indexes;
+ const uint32_t *m_hash_values;
+ const uint32_t *m_hash_offsets;
+ };
};
#endif // liblldb_MappedHash_h_
Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Tue Sep 6 15:57:50 2016
@@ -19,7 +19,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/UUID.h"
#include "lldb/Host/FileSpec.h"
@@ -27,6 +26,7 @@
#include "lldb/Symbol/SymbolContextScope.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/PathMappingList.h"
+#include "lldb/lldb-forward.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private {
@@ -50,1187 +50,1087 @@ namespace lldb_private {
/// The module will parse more detailed information as more queries are
/// made.
//----------------------------------------------------------------------
-class Module :
- public std::enable_shared_from_this<Module>,
- public SymbolContextScope
-{
+class Module : public std::enable_shared_from_this<Module>,
+ public SymbolContextScope {
public:
- // Static functions that can track the lifetime of module objects.
- // This is handy because we might have Module objects that are in
- // shared pointers that aren't in the global module list (from
- // ModuleList). If this is the case we need to know about it.
- // The modules in the global list maintained by these functions
- // can be viewed using the "target modules list" command using the
- // "--global" (-g for short).
- static size_t
- GetNumberAllocatedModules ();
-
- static Module *
- GetAllocatedModuleAtIndex (size_t idx);
-
- static std::recursive_mutex &
- GetAllocationModuleCollectionMutex();
-
- //------------------------------------------------------------------
- /// Construct with file specification and architecture.
- ///
- /// Clients that wish to share modules with other targets should
- /// use ModuleList::GetSharedModule().
- ///
- /// @param[in] file_spec
- /// The file specification for the on disk representation of
- /// this executable image.
- ///
- /// @param[in] arch
- /// The architecture to set as the current architecture in
- /// this module.
- ///
- /// @param[in] object_name
- /// The name of an object in a module used to extract a module
- /// within a module (.a files and modules that contain multiple
- /// architectures).
- ///
- /// @param[in] object_offset
- /// The offset within an existing module used to extract a
- /// module within a module (.a files and modules that contain
- /// multiple architectures).
- //------------------------------------------------------------------
- Module(const FileSpec& file_spec,
- const ArchSpec& arch,
- const ConstString *object_name = nullptr,
- lldb::offset_t object_offset = 0,
- const TimeValue *object_mod_time_ptr = nullptr);
-
- Module (const ModuleSpec &module_spec);
-
- static lldb::ModuleSP
- CreateJITModule (const lldb::ObjectFileJITDelegateSP &delegate_sp);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~Module() override;
-
- bool
- MatchesModuleSpec (const ModuleSpec &module_ref);
-
- //------------------------------------------------------------------
- /// Set the load address for all sections in a module to be the
- /// file address plus \a slide.
- ///
- /// Many times a module will be loaded in a target with a constant
- /// offset applied to all top level sections. This function can
- /// set the load address for all top level sections to be the
- /// section file address + offset.
- ///
- /// @param[in] target
- /// The target in which to apply the section load addresses.
- ///
- /// @param[in] value
- /// if \a value_is_offset is true, then value is the offset to
- /// apply to all file addresses for all top level sections in
- /// the object file as each section load address is being set.
- /// If \a value_is_offset is false, then "value" is the new
- /// absolute base address for the image.
- ///
- /// @param[in] value_is_offset
- /// If \b true, then \a value is an offset to apply to each
- /// file address of each top level section.
- /// If \b false, then \a value is the image base address that
- /// will be used to rigidly slide all loadable sections.
- ///
- /// @param[out] changed
- /// If any section load addresses were changed in \a target,
- /// then \a changed will be set to \b true. Else \a changed
- /// will be set to false. This allows this function to be
- /// called multiple times on the same module for the same
- /// target. If the module hasn't moved, then \a changed will
- /// be false and no module updated notification will need to
- /// be sent out.
- ///
- /// @return
- /// /b True if any sections were successfully loaded in \a target,
- /// /b false otherwise.
- //------------------------------------------------------------------
- bool
- SetLoadAddress (Target &target,
- lldb::addr_t value,
- bool value_is_offset,
- bool &changed);
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- CalculateSymbolContext(SymbolContext* sc) override;
-
- lldb::ModuleSP
- CalculateSymbolContextModule() override;
-
- void
- GetDescription (Stream *s,
- lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
-
- //------------------------------------------------------------------
- /// Get the module path and object name.
- ///
- /// Modules can refer to object files. In this case the specification
- /// is simple and would return the path to the file:
- ///
- /// "/usr/lib/foo.dylib"
- ///
- /// Modules can be .o files inside of a BSD archive (.a file). In
- /// this case, the object specification will look like:
- ///
- /// "/usr/lib/foo.a(bar.o)"
- ///
- /// There are many places where logging wants to log this fully
- /// qualified specification, so we centralize this functionality
- /// here.
- ///
- /// @return
- /// The object path + object name if there is one.
- //------------------------------------------------------------------
- std::string
- GetSpecificationDescription () const;
-
- //------------------------------------------------------------------
- /// Dump a description of this object to a Stream.
- ///
- /// Dump a description of the contents of this object to the
- /// supplied stream \a s. The dumped content will be only what has
- /// been loaded or parsed up to this point at which this function
- /// is called, so this is a good way to see what has been parsed
- /// in a module.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- //------------------------------------------------------------------
- void
- Dump (Stream *s);
-
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
- ///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
- void
- DumpSymbolContext(Stream *s) override;
-
- //------------------------------------------------------------------
- /// Find a symbol in the object file's symbol table.
- ///
- /// @param[in] name
- /// The name of the symbol that we are looking for.
- ///
- /// @param[in] symbol_type
- /// If set to eSymbolTypeAny, find a symbol of any type that
- /// has a name that matches \a name. If set to any other valid
- /// SymbolType enumeration value, then search only for
- /// symbols that match \a symbol_type.
- ///
- /// @return
- /// Returns a valid symbol pointer if a symbol was found,
- /// nullptr otherwise.
- //------------------------------------------------------------------
- const Symbol *
- FindFirstSymbolWithNameAndType (const ConstString &name,
- lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
-
- size_t
- FindSymbolsWithNameAndType (const ConstString &name,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list);
-
- size_t
- FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list);
-
- //------------------------------------------------------------------
- /// Find a function symbols in the object file's symbol table.
- ///
- /// @param[in] name
- /// The name of the symbol that we are looking for.
- ///
- /// @param[in] name_type_mask
- /// A mask that has one or more bitwise OR'ed values from the
- /// lldb::FunctionNameType enumeration type that indicate what
- /// kind of names we are looking for.
- ///
- /// @param[out] sc_list
- /// A list to append any matching symbol contexts to.
- ///
- /// @return
- /// The number of symbol contexts that were added to \a sc_list
- //------------------------------------------------------------------
- size_t
- FindFunctionSymbols (const ConstString &name,
- uint32_t name_type_mask,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find compile units by partial or full path.
- ///
- /// Finds all compile units that match \a path in all of the modules
- /// and returns the results in \a sc_list.
- ///
- /// @param[in] path
- /// The name of the function we are looking for.
- ///
- /// @param[in] append
- /// If \b true, then append any compile units that were found
- /// to \a sc_list. If \b false, then the \a sc_list is cleared
- /// and the contents of \a sc_list are replaced.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindCompileUnits (const FileSpec &path,
- bool append,
- SymbolContextList &sc_list);
-
- //------------------------------------------------------------------
- /// Find functions by name.
- ///
- /// If the function is an inlined function, it will have a block,
- /// representing the inlined function, and the function will be the
- /// containing function. If it is not inlined, then the block will
- /// be NULL.
- ///
- /// @param[in] name
- /// The name of the compile unit we are looking for.
- ///
- /// @param[in] namespace_decl
- /// If valid, a namespace to search in.
- ///
- /// @param[in] name_type_mask
- /// A bit mask of bits that indicate what kind of names should
- /// be used when doing the lookup. Bits include fully qualified
- /// names, base names, C++ methods, or ObjC selectors.
- /// See FunctionNameType for more details.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a sc_list, else
- /// matches replace the contents of \a sc_list.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindFunctions (const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t name_type_mask,
- bool symbols_ok,
- bool inlines_ok,
- bool append,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find functions by name.
- ///
- /// If the function is an inlined function, it will have a block,
- /// representing the inlined function, and the function will be the
- /// containing function. If it is not inlined, then the block will
- /// be NULL.
- ///
- /// @param[in] regex
- /// A regular expression to use when matching the name.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a sc_list, else
- /// matches replace the contents of \a sc_list.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindFunctions (const RegularExpression& regex,
- bool symbols_ok,
- bool inlines_ok,
- bool append,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find addresses by file/line
- ///
- /// @param[in] target_sp
- /// The target the addresses are desired for.
- ///
- /// @param[in] file
- /// Source file to locate.
- ///
- /// @param[in] line
- /// Source line to locate.
- ///
- /// @param[in] function
- /// Optional filter function. Addresses within this function will be
- /// added to the 'local' list. All others will be added to the 'extern' list.
- ///
- /// @param[out] output_local
- /// All matching addresses within 'function'
- ///
- /// @param[out] output_extern
- /// All matching addresses not within 'function'
- void FindAddressesForLine (const lldb::TargetSP target_sp,
- const FileSpec &file, uint32_t line,
- Function *function,
- std::vector<Address> &output_local, std::vector<Address> &output_extern);
-
- //------------------------------------------------------------------
- /// Find global and static variables by name.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @param[in] parent_decl_ctx
- /// If valid, a decl context that results must exist within
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- bool append,
- size_t max_matches,
- VariableList& variable_list);
-
- //------------------------------------------------------------------
- /// Find global and static variables by regular expression.
- ///
- /// @param[in] regex
- /// A regular expression to use when matching the name.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const RegularExpression& regex,
- bool append,
- size_t max_matches,
- VariableList& variable_list);
-
- //------------------------------------------------------------------
- /// Find types by name.
- ///
- /// Type lookups in modules go through the SymbolVendor (which will
- /// use one or more SymbolFile subclasses). The SymbolFile needs to
- /// be able to lookup types by basename and not the fully qualified
- /// typename. This allows the type accelerator tables to stay small,
- /// even with heavily templatized C++. The type search will then
- /// narrow down the search results. If "exact_match" is true, then
- /// the type search will only match exact type name matches. If
- /// "exact_match" is false, the type will match as long as the base
- /// typename matches and as long as any immediate containing
- /// namespaces/class scopes that are specified match. So to search
- /// for a type "d" in "b::c", the name "b::c::d" can be specified
- /// and it will match any class/namespace "b" which contains a
- /// class/namespace "c" which contains type "d". We do this to
- /// allow users to not always have to specify complete scoping on
- /// all expressions, but it also allows for exact matching when
- /// required.
- ///
- /// @param[in] sc
- /// A symbol context that scopes where to extract a type list
- /// from.
- ///
- /// @param[in] type_name
- /// The name of the type we are looking for that is a fully
- /// or partially qualified type name.
- ///
- /// @param[in] exact_match
- /// If \b true, \a type_name is fully qualified and must match
- /// exactly. If \b false, \a type_name is a partially qualified
- /// name where the leading namespaces or classes can be
- /// omitted to make finding types that a user may type
- /// easier.
- ///
- /// @param[out] type_list
- /// A type list gets populated with any matches.
- ///
- /// @return
- /// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t
- FindTypes (const SymbolContext& sc,
- const ConstString &type_name,
- bool exact_match,
- size_t max_matches,
- llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeList& types);
-
- lldb::TypeSP
- FindFirstType (const SymbolContext& sc,
- const ConstString &type_name,
- bool exact_match);
-
- //------------------------------------------------------------------
- /// Find types by name that are in a namespace. This function is
- /// used by the expression parser when searches need to happen in
- /// an exact namespace scope.
- ///
- /// @param[in] sc
- /// A symbol context that scopes where to extract a type list
- /// from.
- ///
- /// @param[in] type_name
- /// The name of a type within a namespace that should not include
- /// any qualifying namespaces (just a type basename).
- ///
- /// @param[in] namespace_decl
- /// The namespace declaration that this type must exist in.
- ///
- /// @param[out] type_list
- /// A type list gets populated with any matches.
- ///
- /// @return
- /// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t
- FindTypesInNamespace (const SymbolContext& sc,
- const ConstString &type_name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches,
- TypeList& type_list);
-
- //------------------------------------------------------------------
- /// Get const accessor for the module architecture.
- ///
- /// @return
- /// A const reference to the architecture object.
- //------------------------------------------------------------------
- const ArchSpec&
- GetArchitecture () const;
-
- //------------------------------------------------------------------
- /// Get const accessor for the module file specification.
- ///
- /// This function returns the file for the module on the host system
- /// that is running LLDB. This can differ from the path on the
- /// platform since we might be doing remote debugging.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- const FileSpec &
- GetFileSpec () const
- {
- return m_file;
- }
-
- //------------------------------------------------------------------
- /// Get accessor for the module platform file specification.
- ///
- /// Platform file refers to the path of the module as it is known on
- /// the remote system on which it is being debugged. For local
- /// debugging this is always the same as Module::GetFileSpec(). But
- /// remote debugging might mention a file "/usr/lib/liba.dylib"
- /// which might be locally downloaded and cached. In this case the
- /// platform file could be something like:
- /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
- /// The file could also be cached in a local developer kit directory.
- ///
- /// @return
- /// A const reference to the file specification object.
- //------------------------------------------------------------------
- const FileSpec &
- GetPlatformFileSpec () const
- {
- if (m_platform_file)
- return m_platform_file;
- return m_file;
- }
-
- void
- SetPlatformFileSpec (const FileSpec &file)
- {
- m_platform_file = file;
- }
-
- const FileSpec &
- GetRemoteInstallFileSpec () const
- {
- return m_remote_install_file;
- }
-
- void
- SetRemoteInstallFileSpec (const FileSpec &file)
- {
- m_remote_install_file = file;
- }
-
- const FileSpec &
- GetSymbolFileFileSpec () const
- {
- return m_symfile_spec;
- }
-
- void
- SetSymbolFileFileSpec (const FileSpec &file);
-
- const TimeValue &
- GetModificationTime () const
- {
- return m_mod_time;
- }
-
- const TimeValue &
- GetObjectModificationTime () const
- {
- return m_object_mod_time;
- }
-
- void
- SetObjectModificationTime (const TimeValue &mod_time)
- {
- m_mod_time = mod_time;
- }
-
- //------------------------------------------------------------------
- /// Tells whether this module is capable of being the main executable
- /// for a process.
- ///
- /// @return
- /// \b true if it is, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsExecutable ();
-
- //------------------------------------------------------------------
- /// Tells whether this module has been loaded in the target passed in.
- /// This call doesn't distinguish between whether the module is loaded
- /// by the dynamic loader, or by a "target module add" type call.
- ///
- /// @param[in] target
- /// The target to check whether this is loaded in.
- ///
- /// @return
- /// \b true if it is, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsLoadedInTarget (Target *target);
-
- bool
- LoadScriptingResourceInTarget(Target *target,
- Error& error,
- Stream* feedback_stream = nullptr);
-
- //------------------------------------------------------------------
- /// Get the number of compile units for this module.
- ///
- /// @return
- /// The number of compile units that the symbol vendor plug-in
- /// finds.
- //------------------------------------------------------------------
- size_t
- GetNumCompileUnits();
-
- lldb::CompUnitSP
- GetCompileUnitAtIndex (size_t idx);
-
- const ConstString &
- GetObjectName() const;
-
- uint64_t
- GetObjectOffset() const
- {
- return m_object_offset;
- }
-
- //------------------------------------------------------------------
- /// Get the object file representation for the current architecture.
- ///
- /// If the object file has not been located or parsed yet, this
- /// function will find the best ObjectFile plug-in that can parse
- /// Module::m_file.
- ///
- /// @return
- /// If Module::m_file does not exist, or no plug-in was found
- /// that can parse the file, or the object file doesn't contain
- /// the current architecture in Module::m_arch, nullptr will be
- /// returned, else a valid object file interface will be
- /// returned. The returned pointer is owned by this object and
- /// remains valid as long as the object is around.
- //------------------------------------------------------------------
- virtual ObjectFile *
- GetObjectFile ();
-
- //------------------------------------------------------------------
- /// Get the unified section list for the module. This is the section
- /// list created by the module's object file and any debug info and
- /// symbol files created by the symbol vendor.
- ///
- /// If the symbol vendor has not been loaded yet, this function
- /// will return the section list for the object file.
- ///
- /// @return
- /// Unified module section list.
- //------------------------------------------------------------------
- virtual SectionList *
- GetSectionList ();
-
- //------------------------------------------------------------------
- /// Notify the module that the file addresses for the Sections have
- /// been updated.
- ///
- /// If the Section file addresses for a module are updated, this
- /// method should be called. Any parts of the module, object file,
- /// or symbol file that has cached those file addresses must invalidate
- /// or update its cache.
- //------------------------------------------------------------------
- virtual void
- SectionFileAddressesChanged ();
-
- uint32_t
- GetVersion (uint32_t *versions, uint32_t num_versions);
-
- //------------------------------------------------------------------
- /// Load an object file from memory.
- ///
- /// If available, the size of the object file in memory may be
- /// passed to avoid additional round trips to process memory.
- /// If the size is not provided, a default value is used. This
- /// value should be large enough to enable the ObjectFile plugins
- /// to read the header of the object file without going back to the
- /// process.
- ///
- /// @return
- /// The object file loaded from memory or nullptr, if the operation
- /// failed (see the `error` for more information in that case).
- //------------------------------------------------------------------
- ObjectFile *
- GetMemoryObjectFile (const lldb::ProcessSP &process_sp,
- lldb::addr_t header_addr,
- Error &error,
- size_t size_to_read = 512);
- //------------------------------------------------------------------
- /// Get the symbol vendor interface for the current architecture.
- ///
- /// If the symbol vendor file has not been located yet, this
- /// function will find the best SymbolVendor plug-in that can
- /// use the current object file.
- ///
- /// @return
- /// If this module does not have a valid object file, or no
- /// plug-in can be found that can use the object file, nullptr will
- /// be returned, else a valid symbol vendor plug-in interface
- /// will be returned. The returned pointer is owned by this
- /// object and remains valid as long as the object is around.
- //------------------------------------------------------------------
- virtual SymbolVendor*
- GetSymbolVendor(bool can_create = true,
- lldb_private::Stream *feedback_strm = nullptr);
-
- //------------------------------------------------------------------
- /// Get accessor the type list for this module.
- ///
- /// @return
- /// A valid type list pointer, or nullptr if there is no valid
- /// symbol vendor for this module.
- //------------------------------------------------------------------
- TypeList*
- GetTypeList ();
-
- //------------------------------------------------------------------
- /// Get a pointer to the UUID value contained in this object.
- ///
- /// If the executable image file doesn't not have a UUID value built
- /// into the file format, an MD5 checksum of the entire file, or
- /// slice of the file for the current architecture should be used.
- ///
- /// @return
- /// A const pointer to the internal copy of the UUID value in
- /// this module if this module has a valid UUID value, NULL
- /// otherwise.
- //------------------------------------------------------------------
- const lldb_private::UUID &
- GetUUID ();
-
- //------------------------------------------------------------------
- /// A debugging function that will cause everything in a module to
- /// be parsed.
- ///
- /// All compile units will be parsed, along with all globals and
- /// static variables and all functions for those compile units.
- /// All types, scopes, local variables, static variables, global
- /// variables, and line tables will be parsed. This can be used
- /// prior to dumping a module to see a complete list of the
- /// resulting debug information that gets parsed, or as a debug
- /// function to ensure that the module can consume all of the
- /// debug data the symbol vendor provides.
- //------------------------------------------------------------------
- void
- ParseAllDebugSymbols();
-
- bool
- ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr);
-
- //------------------------------------------------------------------
- /// Resolve the symbol context for the given address.
- ///
- /// Tries to resolve the matching symbol context based on a lookup
- /// from the current symbol vendor. If the lazy lookup fails,
- /// an attempt is made to parse the eh_frame section to handle
- /// stripped symbols. If this fails, an attempt is made to resolve
- /// the symbol to the previous address to handle the case of a
- /// function with a tail call.
- ///
- /// Use properties of the modified SymbolContext to inspect any
- /// resolved target, module, compilation unit, symbol, function,
- /// function block or line entry. Use the return value to determine
- /// which of these properties have been modified.
- ///
- /// @param[in] so_addr
- /// A load address to resolve.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see SymbolContext::Scope).
- /// A combination of flags from the enumeration SymbolContextItem
- /// requesting a resolution depth. Note that the flags that are
- /// actually resolved may be a superset of the requested flags.
- /// For instance, eSymbolContextSymbol requires resolution of
- /// eSymbolContextModule, and eSymbolContextFunction requires
- /// eSymbolContextSymbol.
- ///
- /// @param[out] sc
- /// The SymbolContext that is modified based on symbol resolution.
- ///
- /// @param[in] resolve_tail_call_address
- /// Determines if so_addr should resolve to a symbol in the case
- /// of a function whose last instruction is a call. In this case,
- /// the PC can be one past the address range of the function.
- ///
- /// @return
- /// The scope that has been resolved (see SymbolContext::Scope).
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope,
- SymbolContext& sc, bool resolve_tail_call_address = false);
-
- //------------------------------------------------------------------
- /// Resolve items in the symbol context for a given file and line.
- ///
- /// Tries to resolve \a file_path and \a line to a list of matching
- /// symbol contexts.
- ///
- /// The line table entries contains addresses that can be used to
- /// further resolve the values in each match: the function, block,
- /// symbol. Care should be taken to minimize the amount of
- /// information that is requested to only what is needed --
- /// typically the module, compile unit, line table and line table
- /// entry are sufficient.
- ///
- /// @param[in] file_path
- /// A path to a source file to match. If \a file_path does not
- /// specify a directory, then this query will match all files
- /// whose base filename matches. If \a file_path does specify
- /// a directory, the fullpath to the file must match.
- ///
- /// @param[in] line
- /// The source line to match, or zero if just the compile unit
- /// should be resolved.
- ///
- /// @param[in] check_inlines
- /// Check for inline file and line number matches. This option
- /// should be used sparingly as it will cause all line tables
- /// for every compile unit to be parsed and searched for
- /// matching inline file entries.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see
- /// SymbolContext::Scope).
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets matching symbols contexts
- /// appended to.
- ///
- /// @return
- /// The number of matches that were added to \a sc_list.
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Resolve items in the symbol context for a given file and line.
- ///
- /// Tries to resolve \a file_spec and \a line to a list of matching
- /// symbol contexts.
- ///
- /// The line table entries contains addresses that can be used to
- /// further resolve the values in each match: the function, block,
- /// symbol. Care should be taken to minimize the amount of
- /// information that is requested to only what is needed --
- /// typically the module, compile unit, line table and line table
- /// entry are sufficient.
- ///
- /// @param[in] file_spec
- /// A file spec to a source file to match. If \a file_path does
- /// not specify a directory, then this query will match all
- /// files whose base filename matches. If \a file_path does
- /// specify a directory, the fullpath to the file must match.
- ///
- /// @param[in] line
- /// The source line to match, or zero if just the compile unit
- /// should be resolved.
- ///
- /// @param[in] check_inlines
- /// Check for inline file and line number matches. This option
- /// should be used sparingly as it will cause all line tables
- /// for every compile unit to be parsed and searched for
- /// matching inline file entries.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see
- /// SymbolContext::Scope).
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// A integer that contains SymbolContext::Scope bits set for
- /// each item that was successfully resolved.
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
-
- void
- SetFileSpecAndObjectName (const FileSpec &file,
- const ConstString &object_name);
-
- bool
- GetIsDynamicLinkEditor ();
-
- TypeSystem *
- GetTypeSystemForLanguage (lldb::LanguageType language);
-
- // Special error functions that can do printf style formatting that will prepend the message with
- // something appropriate for this module (like the architecture, path and object name (if any)).
- // This centralizes code so that everyone doesn't need to format their error and log messages on
- // their own and keeps the output a bit more consistent.
- void
- LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- void
- LogMessageVerboseBacktrace (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- void
- ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- void
- ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- // Only report an error once when the module is first detected to be modified
- // so we don't spam the console with many messages.
- void
- ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- //------------------------------------------------------------------
- // Return true if the file backing this module has changed since the
- // module was originally created since we saved the initial file
- // modification time when the module first gets created.
- //------------------------------------------------------------------
- bool
- FileHasChanged () const;
-
- //------------------------------------------------------------------
- // SymbolVendor, SymbolFile and ObjectFile member objects should
- // lock the module mutex to avoid deadlocks.
- //------------------------------------------------------------------
- std::recursive_mutex &
- GetMutex() const
- {
- return m_mutex;
- }
-
- PathMappingList &
- GetSourceMappingList ()
- {
- return m_source_mappings;
- }
-
- const PathMappingList &
- GetSourceMappingList () const
- {
- return m_source_mappings;
- }
-
- //------------------------------------------------------------------
- /// Finds a source file given a file spec using the module source
- /// path remappings (if any).
- ///
- /// Tries to resolve \a orig_spec by checking the module source path
- /// remappings. It makes sure the file exists, so this call can be
- /// expensive if the remappings are on a network file system, so
- /// use this function sparingly (not in a tight debug info parsing
- /// loop).
- ///
- /// @param[in] orig_spec
- /// The original source file path to try and remap.
- ///
- /// @param[out] new_spec
- /// The newly remapped filespec that is guaranteed to exist.
- ///
- /// @return
- /// /b true if \a orig_spec was successfully located and
- /// \a new_spec is filled in with an existing file spec,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
-
- //------------------------------------------------------------------
- /// Remaps a source file given \a path into \a new_path.
- ///
- /// Remaps \a path if any source remappings match. This function
- /// does NOT stat the file system so it can be used in tight loops
- /// where debug info is being parsed.
- ///
- /// @param[in] path
- /// The original source file path to try and remap.
- ///
- /// @param[out] new_path
- /// The newly remapped filespec that is may or may not exist.
- ///
- /// @return
- /// /b true if \a path was successfully located and \a new_path
- /// is filled in with a new source path, \b false otherwise.
- //------------------------------------------------------------------
- bool
- RemapSourceFile (const char *path, std::string &new_path) const;
-
- //----------------------------------------------------------------------
- /// @class LookupInfo Module.h "lldb/Core/Module.h"
- /// @brief A class that encapsulates name lookup information.
- ///
- /// Users can type a wide variety of partial names when setting
- /// breakpoints by name or when looking for functions by name.
- /// SymbolVendor and SymbolFile objects are only required to implement
- /// name lookup for function basenames and for fully mangled names.
- /// This means if the user types in a partial name, we must reduce this
- /// to a name lookup that will work with all SymbolFile objects. So we
- /// might reduce a name lookup to look for a basename, and then prune
- /// out any results that don't match.
- ///
- /// The "m_name" member variable represents the name as it was typed
- /// by the user. "m_lookup_name" will be the name we actually search
- /// for through the symbol or objects files. Lanaguage is included in
- /// case we need to filter results by language at a later date. The
- /// "m_name_type_mask" member variable tells us what kinds of names we
- /// are looking for and can help us prune out unwanted results.
- ///
- /// Function lookups are done in Module.cpp, ModuleList.cpp and in
- /// BreakpointResolverName.cpp and they all now use this class to do
- /// lookups correctly.
- //----------------------------------------------------------------------
- class LookupInfo
- {
- public:
- LookupInfo() :
- m_name(),
- m_lookup_name(),
- m_language(lldb::eLanguageTypeUnknown),
- m_name_type_mask(0),
- m_match_name_after_lookup(false)
- {
- }
-
- LookupInfo(const ConstString &name, uint32_t name_type_mask, lldb::LanguageType language);
-
- const ConstString &
- GetName() const
- {
- return m_name;
- }
-
- void
- SetName(const ConstString &name)
- {
- m_name = name;
- }
-
- const ConstString &
- GetLookupName() const
- {
- return m_lookup_name;
- }
-
- void
- SetLookupName(const ConstString &name)
- {
- m_lookup_name = name;
- }
-
- uint32_t
- GetNameTypeMask() const
- {
- return m_name_type_mask;
- }
-
- void
- SetNameTypeMask(uint32_t mask)
- {
- m_name_type_mask = mask;
- }
-
- void
- Prune(SymbolContextList &sc_list, size_t start_idx) const;
-
- protected:
- ConstString m_name; ///< What the user originally typed
- ConstString m_lookup_name; ///< The actual name will lookup when calling in the object or symbol file
- lldb::LanguageType m_language; ///< Limit matches to only be for this language
- uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType that indicate what kind of names we are looking for
- bool m_match_name_after_lookup; ///< If \b true, then demangled names that match will need to contain "m_name" in order to be considered a match
- };
+ // Static functions that can track the lifetime of module objects.
+ // This is handy because we might have Module objects that are in
+ // shared pointers that aren't in the global module list (from
+ // ModuleList). If this is the case we need to know about it.
+ // The modules in the global list maintained by these functions
+ // can be viewed using the "target modules list" command using the
+ // "--global" (-g for short).
+ static size_t GetNumberAllocatedModules();
+
+ static Module *GetAllocatedModuleAtIndex(size_t idx);
+
+ static std::recursive_mutex &GetAllocationModuleCollectionMutex();
+
+ //------------------------------------------------------------------
+ /// Construct with file specification and architecture.
+ ///
+ /// Clients that wish to share modules with other targets should
+ /// use ModuleList::GetSharedModule().
+ ///
+ /// @param[in] file_spec
+ /// The file specification for the on disk representation of
+ /// this executable image.
+ ///
+ /// @param[in] arch
+ /// The architecture to set as the current architecture in
+ /// this module.
+ ///
+ /// @param[in] object_name
+ /// The name of an object in a module used to extract a module
+ /// within a module (.a files and modules that contain multiple
+ /// architectures).
+ ///
+ /// @param[in] object_offset
+ /// The offset within an existing module used to extract a
+ /// module within a module (.a files and modules that contain
+ /// multiple architectures).
+ //------------------------------------------------------------------
+ Module(const FileSpec &file_spec, const ArchSpec &arch,
+ const ConstString *object_name = nullptr,
+ lldb::offset_t object_offset = 0,
+ const TimeValue *object_mod_time_ptr = nullptr);
+
+ Module(const ModuleSpec &module_spec);
+
+ static lldb::ModuleSP
+ CreateJITModule(const lldb::ObjectFileJITDelegateSP &delegate_sp);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~Module() override;
+
+ bool MatchesModuleSpec(const ModuleSpec &module_ref);
+
+ //------------------------------------------------------------------
+ /// Set the load address for all sections in a module to be the
+ /// file address plus \a slide.
+ ///
+ /// Many times a module will be loaded in a target with a constant
+ /// offset applied to all top level sections. This function can
+ /// set the load address for all top level sections to be the
+ /// section file address + offset.
+ ///
+ /// @param[in] target
+ /// The target in which to apply the section load addresses.
+ ///
+ /// @param[in] value
+ /// if \a value_is_offset is true, then value is the offset to
+ /// apply to all file addresses for all top level sections in
+ /// the object file as each section load address is being set.
+ /// If \a value_is_offset is false, then "value" is the new
+ /// absolute base address for the image.
+ ///
+ /// @param[in] value_is_offset
+ /// If \b true, then \a value is an offset to apply to each
+ /// file address of each top level section.
+ /// If \b false, then \a value is the image base address that
+ /// will be used to rigidly slide all loadable sections.
+ ///
+ /// @param[out] changed
+ /// If any section load addresses were changed in \a target,
+ /// then \a changed will be set to \b true. Else \a changed
+ /// will be set to false. This allows this function to be
+ /// called multiple times on the same module for the same
+ /// target. If the module hasn't moved, then \a changed will
+ /// be false and no module updated notification will need to
+ /// be sent out.
+ ///
+ /// @return
+ /// /b True if any sections were successfully loaded in \a target,
+ /// /b false otherwise.
+ //------------------------------------------------------------------
+ bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset,
+ bool &changed);
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void CalculateSymbolContext(SymbolContext *sc) override;
+
+ lldb::ModuleSP CalculateSymbolContextModule() override;
+
+ void
+ GetDescription(Stream *s,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
+
+ //------------------------------------------------------------------
+ /// Get the module path and object name.
+ ///
+ /// Modules can refer to object files. In this case the specification
+ /// is simple and would return the path to the file:
+ ///
+ /// "/usr/lib/foo.dylib"
+ ///
+ /// Modules can be .o files inside of a BSD archive (.a file). In
+ /// this case, the object specification will look like:
+ ///
+ /// "/usr/lib/foo.a(bar.o)"
+ ///
+ /// There are many places where logging wants to log this fully
+ /// qualified specification, so we centralize this functionality
+ /// here.
+ ///
+ /// @return
+ /// The object path + object name if there is one.
+ //------------------------------------------------------------------
+ std::string GetSpecificationDescription() const;
+
+ //------------------------------------------------------------------
+ /// Dump a description of this object to a Stream.
+ ///
+ /// Dump a description of the contents of this object to the
+ /// supplied stream \a s. The dumped content will be only what has
+ /// been loaded or parsed up to this point at which this function
+ /// is called, so this is a good way to see what has been parsed
+ /// in a module.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ //------------------------------------------------------------------
+ void Dump(Stream *s);
+
+ //------------------------------------------------------------------
+ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ ///
+ /// @see SymbolContextScope
+ //------------------------------------------------------------------
+ void DumpSymbolContext(Stream *s) override;
+
+ //------------------------------------------------------------------
+ /// Find a symbol in the object file's symbol table.
+ ///
+ /// @param[in] name
+ /// The name of the symbol that we are looking for.
+ ///
+ /// @param[in] symbol_type
+ /// If set to eSymbolTypeAny, find a symbol of any type that
+ /// has a name that matches \a name. If set to any other valid
+ /// SymbolType enumeration value, then search only for
+ /// symbols that match \a symbol_type.
+ ///
+ /// @return
+ /// Returns a valid symbol pointer if a symbol was found,
+ /// nullptr otherwise.
+ //------------------------------------------------------------------
+ const Symbol *FindFirstSymbolWithNameAndType(
+ const ConstString &name,
+ lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
+
+ size_t FindSymbolsWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list);
+
+ size_t FindSymbolsMatchingRegExAndType(const RegularExpression ®ex,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find a function symbols in the object file's symbol table.
+ ///
+ /// @param[in] name
+ /// The name of the symbol that we are looking for.
+ ///
+ /// @param[in] name_type_mask
+ /// A mask that has one or more bitwise OR'ed values from the
+ /// lldb::FunctionNameType enumeration type that indicate what
+ /// kind of names we are looking for.
+ ///
+ /// @param[out] sc_list
+ /// A list to append any matching symbol contexts to.
+ ///
+ /// @return
+ /// The number of symbol contexts that were added to \a sc_list
+ //------------------------------------------------------------------
+ size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find compile units by partial or full path.
+ ///
+ /// Finds all compile units that match \a path in all of the modules
+ /// and returns the results in \a sc_list.
+ ///
+ /// @param[in] path
+ /// The name of the function we are looking for.
+ ///
+ /// @param[in] append
+ /// If \b true, then append any compile units that were found
+ /// to \a sc_list. If \b false, then the \a sc_list is cleared
+ /// and the contents of \a sc_list are replaced.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindCompileUnits(const FileSpec &path, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// If the function is an inlined function, it will have a block,
+ /// representing the inlined function, and the function will be the
+ /// containing function. If it is not inlined, then the block will
+ /// be NULL.
+ ///
+ /// @param[in] name
+ /// The name of the compile unit we are looking for.
+ ///
+ /// @param[in] namespace_decl
+ /// If valid, a namespace to search in.
+ ///
+ /// @param[in] name_type_mask
+ /// A bit mask of bits that indicate what kind of names should
+ /// be used when doing the lookup. Bits include fully qualified
+ /// names, base names, C++ methods, or ObjC selectors.
+ /// See FunctionNameType for more details.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a sc_list, else
+ /// matches replace the contents of \a sc_list.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindFunctions(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ uint32_t name_type_mask, bool symbols_ok,
+ bool inlines_ok, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find functions by name.
+ ///
+ /// If the function is an inlined function, it will have a block,
+ /// representing the inlined function, and the function will be the
+ /// containing function. If it is not inlined, then the block will
+ /// be NULL.
+ ///
+ /// @param[in] regex
+ /// A regular expression to use when matching the name.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a sc_list, else
+ /// matches replace the contents of \a sc_list.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindFunctions(const RegularExpression ®ex, bool symbols_ok,
+ bool inlines_ok, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find addresses by file/line
+ ///
+ /// @param[in] target_sp
+ /// The target the addresses are desired for.
+ ///
+ /// @param[in] file
+ /// Source file to locate.
+ ///
+ /// @param[in] line
+ /// Source line to locate.
+ ///
+ /// @param[in] function
+ /// Optional filter function. Addresses within this function will be
+ /// added to the 'local' list. All others will be added to the 'extern'
+ /// list.
+ ///
+ /// @param[out] output_local
+ /// All matching addresses within 'function'
+ ///
+ /// @param[out] output_extern
+ /// All matching addresses not within 'function'
+ void FindAddressesForLine(const lldb::TargetSP target_sp,
+ const FileSpec &file, uint32_t line,
+ Function *function,
+ std::vector<Address> &output_local,
+ std::vector<Address> &output_extern);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] parent_decl_ctx
+ /// If valid, a decl context that results must exist within
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx,
+ bool append, size_t max_matches,
+ VariableList &variable_list);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by regular expression.
+ ///
+ /// @param[in] regex
+ /// A regular expression to use when matching the name.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const RegularExpression ®ex, bool append,
+ size_t max_matches, VariableList &variable_list);
+
+ //------------------------------------------------------------------
+ /// Find types by name.
+ ///
+ /// Type lookups in modules go through the SymbolVendor (which will
+ /// use one or more SymbolFile subclasses). The SymbolFile needs to
+ /// be able to lookup types by basename and not the fully qualified
+ /// typename. This allows the type accelerator tables to stay small,
+ /// even with heavily templatized C++. The type search will then
+ /// narrow down the search results. If "exact_match" is true, then
+ /// the type search will only match exact type name matches. If
+ /// "exact_match" is false, the type will match as long as the base
+ /// typename matches and as long as any immediate containing
+ /// namespaces/class scopes that are specified match. So to search
+ /// for a type "d" in "b::c", the name "b::c::d" can be specified
+ /// and it will match any class/namespace "b" which contains a
+ /// class/namespace "c" which contains type "d". We do this to
+ /// allow users to not always have to specify complete scoping on
+ /// all expressions, but it also allows for exact matching when
+ /// required.
+ ///
+ /// @param[in] sc
+ /// A symbol context that scopes where to extract a type list
+ /// from.
+ ///
+ /// @param[in] type_name
+ /// The name of the type we are looking for that is a fully
+ /// or partially qualified type name.
+ ///
+ /// @param[in] exact_match
+ /// If \b true, \a type_name is fully qualified and must match
+ /// exactly. If \b false, \a type_name is a partially qualified
+ /// name where the leading namespaces or classes can be
+ /// omitted to make finding types that a user may type
+ /// easier.
+ ///
+ /// @param[out] type_list
+ /// A type list gets populated with any matches.
+ ///
+ /// @return
+ /// The number of matches added to \a type_list.
+ //------------------------------------------------------------------
+ size_t
+ FindTypes(const SymbolContext &sc, const ConstString &type_name,
+ bool exact_match, size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeList &types);
+
+ lldb::TypeSP FindFirstType(const SymbolContext &sc,
+ const ConstString &type_name, bool exact_match);
+
+ //------------------------------------------------------------------
+ /// Find types by name that are in a namespace. This function is
+ /// used by the expression parser when searches need to happen in
+ /// an exact namespace scope.
+ ///
+ /// @param[in] sc
+ /// A symbol context that scopes where to extract a type list
+ /// from.
+ ///
+ /// @param[in] type_name
+ /// The name of a type within a namespace that should not include
+ /// any qualifying namespaces (just a type basename).
+ ///
+ /// @param[in] namespace_decl
+ /// The namespace declaration that this type must exist in.
+ ///
+ /// @param[out] type_list
+ /// A type list gets populated with any matches.
+ ///
+ /// @return
+ /// The number of matches added to \a type_list.
+ //------------------------------------------------------------------
+ size_t FindTypesInNamespace(const SymbolContext &sc,
+ const ConstString &type_name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, TypeList &type_list);
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module architecture.
+ ///
+ /// @return
+ /// A const reference to the architecture object.
+ //------------------------------------------------------------------
+ const ArchSpec &GetArchitecture() const;
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module file specification.
+ ///
+ /// This function returns the file for the module on the host system
+ /// that is running LLDB. This can differ from the path on the
+ /// platform since we might be doing remote debugging.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ const FileSpec &GetFileSpec() const { return m_file; }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the module platform file specification.
+ ///
+ /// Platform file refers to the path of the module as it is known on
+ /// the remote system on which it is being debugged. For local
+ /// debugging this is always the same as Module::GetFileSpec(). But
+ /// remote debugging might mention a file "/usr/lib/liba.dylib"
+ /// which might be locally downloaded and cached. In this case the
+ /// platform file could be something like:
+ /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
+ /// The file could also be cached in a local developer kit directory.
+ ///
+ /// @return
+ /// A const reference to the file specification object.
+ //------------------------------------------------------------------
+ const FileSpec &GetPlatformFileSpec() const {
+ if (m_platform_file)
+ return m_platform_file;
+ return m_file;
+ }
+
+ void SetPlatformFileSpec(const FileSpec &file) { m_platform_file = file; }
+
+ const FileSpec &GetRemoteInstallFileSpec() const {
+ return m_remote_install_file;
+ }
+
+ void SetRemoteInstallFileSpec(const FileSpec &file) {
+ m_remote_install_file = file;
+ }
+
+ const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; }
+
+ void SetSymbolFileFileSpec(const FileSpec &file);
+
+ const TimeValue &GetModificationTime() const { return m_mod_time; }
+
+ const TimeValue &GetObjectModificationTime() const {
+ return m_object_mod_time;
+ }
+
+ void SetObjectModificationTime(const TimeValue &mod_time) {
+ m_mod_time = mod_time;
+ }
+
+ //------------------------------------------------------------------
+ /// Tells whether this module is capable of being the main executable
+ /// for a process.
+ ///
+ /// @return
+ /// \b true if it is, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsExecutable();
+
+ //------------------------------------------------------------------
+ /// Tells whether this module has been loaded in the target passed in.
+ /// This call doesn't distinguish between whether the module is loaded
+ /// by the dynamic loader, or by a "target module add" type call.
+ ///
+ /// @param[in] target
+ /// The target to check whether this is loaded in.
+ ///
+ /// @return
+ /// \b true if it is, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsLoadedInTarget(Target *target);
+
+ bool LoadScriptingResourceInTarget(Target *target, Error &error,
+ Stream *feedback_stream = nullptr);
+
+ //------------------------------------------------------------------
+ /// Get the number of compile units for this module.
+ ///
+ /// @return
+ /// The number of compile units that the symbol vendor plug-in
+ /// finds.
+ //------------------------------------------------------------------
+ size_t GetNumCompileUnits();
+
+ lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
+
+ const ConstString &GetObjectName() const;
+
+ uint64_t GetObjectOffset() const { return m_object_offset; }
+
+ //------------------------------------------------------------------
+ /// Get the object file representation for the current architecture.
+ ///
+ /// If the object file has not been located or parsed yet, this
+ /// function will find the best ObjectFile plug-in that can parse
+ /// Module::m_file.
+ ///
+ /// @return
+ /// If Module::m_file does not exist, or no plug-in was found
+ /// that can parse the file, or the object file doesn't contain
+ /// the current architecture in Module::m_arch, nullptr will be
+ /// returned, else a valid object file interface will be
+ /// returned. The returned pointer is owned by this object and
+ /// remains valid as long as the object is around.
+ //------------------------------------------------------------------
+ virtual ObjectFile *GetObjectFile();
+
+ //------------------------------------------------------------------
+ /// Get the unified section list for the module. This is the section
+ /// list created by the module's object file and any debug info and
+ /// symbol files created by the symbol vendor.
+ ///
+ /// If the symbol vendor has not been loaded yet, this function
+ /// will return the section list for the object file.
+ ///
+ /// @return
+ /// Unified module section list.
+ //------------------------------------------------------------------
+ virtual SectionList *GetSectionList();
+
+ //------------------------------------------------------------------
+ /// Notify the module that the file addresses for the Sections have
+ /// been updated.
+ ///
+ /// If the Section file addresses for a module are updated, this
+ /// method should be called. Any parts of the module, object file,
+ /// or symbol file that has cached those file addresses must invalidate
+ /// or update its cache.
+ //------------------------------------------------------------------
+ virtual void SectionFileAddressesChanged();
+
+ uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
+
+ //------------------------------------------------------------------
+ /// Load an object file from memory.
+ ///
+ /// If available, the size of the object file in memory may be
+ /// passed to avoid additional round trips to process memory.
+ /// If the size is not provided, a default value is used. This
+ /// value should be large enough to enable the ObjectFile plugins
+ /// to read the header of the object file without going back to the
+ /// process.
+ ///
+ /// @return
+ /// The object file loaded from memory or nullptr, if the operation
+ /// failed (see the `error` for more information in that case).
+ //------------------------------------------------------------------
+ ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr, Error &error,
+ size_t size_to_read = 512);
+ //------------------------------------------------------------------
+ /// Get the symbol vendor interface for the current architecture.
+ ///
+ /// If the symbol vendor file has not been located yet, this
+ /// function will find the best SymbolVendor plug-in that can
+ /// use the current object file.
+ ///
+ /// @return
+ /// If this module does not have a valid object file, or no
+ /// plug-in can be found that can use the object file, nullptr will
+ /// be returned, else a valid symbol vendor plug-in interface
+ /// will be returned. The returned pointer is owned by this
+ /// object and remains valid as long as the object is around.
+ //------------------------------------------------------------------
+ virtual SymbolVendor *
+ GetSymbolVendor(bool can_create = true,
+ lldb_private::Stream *feedback_strm = nullptr);
+
+ //------------------------------------------------------------------
+ /// Get accessor the type list for this module.
+ ///
+ /// @return
+ /// A valid type list pointer, or nullptr if there is no valid
+ /// symbol vendor for this module.
+ //------------------------------------------------------------------
+ TypeList *GetTypeList();
+
+ //------------------------------------------------------------------
+ /// Get a pointer to the UUID value contained in this object.
+ ///
+ /// If the executable image file doesn't not have a UUID value built
+ /// into the file format, an MD5 checksum of the entire file, or
+ /// slice of the file for the current architecture should be used.
+ ///
+ /// @return
+ /// A const pointer to the internal copy of the UUID value in
+ /// this module if this module has a valid UUID value, NULL
+ /// otherwise.
+ //------------------------------------------------------------------
+ const lldb_private::UUID &GetUUID();
+
+ //------------------------------------------------------------------
+ /// A debugging function that will cause everything in a module to
+ /// be parsed.
+ ///
+ /// All compile units will be parsed, along with all globals and
+ /// static variables and all functions for those compile units.
+ /// All types, scopes, local variables, static variables, global
+ /// variables, and line tables will be parsed. This can be used
+ /// prior to dumping a module to see a complete list of the
+ /// resulting debug information that gets parsed, or as a debug
+ /// function to ensure that the module can consume all of the
+ /// debug data the symbol vendor provides.
+ //------------------------------------------------------------------
+ void ParseAllDebugSymbols();
+
+ bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr);
+
+ //------------------------------------------------------------------
+ /// Resolve the symbol context for the given address.
+ ///
+ /// Tries to resolve the matching symbol context based on a lookup
+ /// from the current symbol vendor. If the lazy lookup fails,
+ /// an attempt is made to parse the eh_frame section to handle
+ /// stripped symbols. If this fails, an attempt is made to resolve
+ /// the symbol to the previous address to handle the case of a
+ /// function with a tail call.
+ ///
+ /// Use properties of the modified SymbolContext to inspect any
+ /// resolved target, module, compilation unit, symbol, function,
+ /// function block or line entry. Use the return value to determine
+ /// which of these properties have been modified.
+ ///
+ /// @param[in] so_addr
+ /// A load address to resolve.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see SymbolContext::Scope).
+ /// A combination of flags from the enumeration SymbolContextItem
+ /// requesting a resolution depth. Note that the flags that are
+ /// actually resolved may be a superset of the requested flags.
+ /// For instance, eSymbolContextSymbol requires resolution of
+ /// eSymbolContextModule, and eSymbolContextFunction requires
+ /// eSymbolContextSymbol.
+ ///
+ /// @param[out] sc
+ /// The SymbolContext that is modified based on symbol resolution.
+ ///
+ /// @param[in] resolve_tail_call_address
+ /// Determines if so_addr should resolve to a symbol in the case
+ /// of a function whose last instruction is a call. In this case,
+ /// the PC can be one past the address range of the function.
+ ///
+ /// @return
+ /// The scope that has been resolved (see SymbolContext::Scope).
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t
+ ResolveSymbolContextForAddress(const Address &so_addr, uint32_t resolve_scope,
+ SymbolContext &sc,
+ bool resolve_tail_call_address = false);
+
+ //------------------------------------------------------------------
+ /// Resolve items in the symbol context for a given file and line.
+ ///
+ /// Tries to resolve \a file_path and \a line to a list of matching
+ /// symbol contexts.
+ ///
+ /// The line table entries contains addresses that can be used to
+ /// further resolve the values in each match: the function, block,
+ /// symbol. Care should be taken to minimize the amount of
+ /// information that is requested to only what is needed --
+ /// typically the module, compile unit, line table and line table
+ /// entry are sufficient.
+ ///
+ /// @param[in] file_path
+ /// A path to a source file to match. If \a file_path does not
+ /// specify a directory, then this query will match all files
+ /// whose base filename matches. If \a file_path does specify
+ /// a directory, the fullpath to the file must match.
+ ///
+ /// @param[in] line
+ /// The source line to match, or zero if just the compile unit
+ /// should be resolved.
+ ///
+ /// @param[in] check_inlines
+ /// Check for inline file and line number matches. This option
+ /// should be used sparingly as it will cause all line tables
+ /// for every compile unit to be parsed and searched for
+ /// matching inline file entries.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see
+ /// SymbolContext::Scope).
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets matching symbols contexts
+ /// appended to.
+ ///
+ /// @return
+ /// The number of matches that were added to \a sc_list.
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line,
+ bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Resolve items in the symbol context for a given file and line.
+ ///
+ /// Tries to resolve \a file_spec and \a line to a list of matching
+ /// symbol contexts.
+ ///
+ /// The line table entries contains addresses that can be used to
+ /// further resolve the values in each match: the function, block,
+ /// symbol. Care should be taken to minimize the amount of
+ /// information that is requested to only what is needed --
+ /// typically the module, compile unit, line table and line table
+ /// entry are sufficient.
+ ///
+ /// @param[in] file_spec
+ /// A file spec to a source file to match. If \a file_path does
+ /// not specify a directory, then this query will match all
+ /// files whose base filename matches. If \a file_path does
+ /// specify a directory, the fullpath to the file must match.
+ ///
+ /// @param[in] line
+ /// The source line to match, or zero if just the compile unit
+ /// should be resolved.
+ ///
+ /// @param[in] check_inlines
+ /// Check for inline file and line number matches. This option
+ /// should be used sparingly as it will cause all line tables
+ /// for every compile unit to be parsed and searched for
+ /// matching inline file entries.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see
+ /// SymbolContext::Scope).
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// A integer that contains SymbolContext::Scope bits set for
+ /// each item that was successfully resolved.
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list);
+
+ void SetFileSpecAndObjectName(const FileSpec &file,
+ const ConstString &object_name);
+
+ bool GetIsDynamicLinkEditor();
+
+ TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language);
+
+ // Special error functions that can do printf style formatting that will
+ // prepend the message with
+ // something appropriate for this module (like the architecture, path and
+ // object name (if any)).
+ // This centralizes code so that everyone doesn't need to format their error
+ // and log messages on
+ // their own and keeps the output a bit more consistent.
+ void LogMessage(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ void LogMessageVerboseBacktrace(Log *log, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ void ReportWarning(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ void ReportError(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ // Only report an error once when the module is first detected to be modified
+ // so we don't spam the console with many messages.
+ void ReportErrorIfModifyDetected(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ //------------------------------------------------------------------
+ // Return true if the file backing this module has changed since the
+ // module was originally created since we saved the initial file
+ // modification time when the module first gets created.
+ //------------------------------------------------------------------
+ bool FileHasChanged() const;
+
+ //------------------------------------------------------------------
+ // SymbolVendor, SymbolFile and ObjectFile member objects should
+ // lock the module mutex to avoid deadlocks.
+ //------------------------------------------------------------------
+ std::recursive_mutex &GetMutex() const { return m_mutex; }
+
+ PathMappingList &GetSourceMappingList() { return m_source_mappings; }
+
+ const PathMappingList &GetSourceMappingList() const {
+ return m_source_mappings;
+ }
+
+ //------------------------------------------------------------------
+ /// Finds a source file given a file spec using the module source
+ /// path remappings (if any).
+ ///
+ /// Tries to resolve \a orig_spec by checking the module source path
+ /// remappings. It makes sure the file exists, so this call can be
+ /// expensive if the remappings are on a network file system, so
+ /// use this function sparingly (not in a tight debug info parsing
+ /// loop).
+ ///
+ /// @param[in] orig_spec
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_spec
+ /// The newly remapped filespec that is guaranteed to exist.
+ ///
+ /// @return
+ /// /b true if \a orig_spec was successfully located and
+ /// \a new_spec is filled in with an existing file spec,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
+
+ //------------------------------------------------------------------
+ /// Remaps a source file given \a path into \a new_path.
+ ///
+ /// Remaps \a path if any source remappings match. This function
+ /// does NOT stat the file system so it can be used in tight loops
+ /// where debug info is being parsed.
+ ///
+ /// @param[in] path
+ /// The original source file path to try and remap.
+ ///
+ /// @param[out] new_path
+ /// The newly remapped filespec that is may or may not exist.
+ ///
+ /// @return
+ /// /b true if \a path was successfully located and \a new_path
+ /// is filled in with a new source path, \b false otherwise.
+ //------------------------------------------------------------------
+ bool RemapSourceFile(const char *path, std::string &new_path) const;
+
+ //----------------------------------------------------------------------
+ /// @class LookupInfo Module.h "lldb/Core/Module.h"
+ /// @brief A class that encapsulates name lookup information.
+ ///
+ /// Users can type a wide variety of partial names when setting
+ /// breakpoints by name or when looking for functions by name.
+ /// SymbolVendor and SymbolFile objects are only required to implement
+ /// name lookup for function basenames and for fully mangled names.
+ /// This means if the user types in a partial name, we must reduce this
+ /// to a name lookup that will work with all SymbolFile objects. So we
+ /// might reduce a name lookup to look for a basename, and then prune
+ /// out any results that don't match.
+ ///
+ /// The "m_name" member variable represents the name as it was typed
+ /// by the user. "m_lookup_name" will be the name we actually search
+ /// for through the symbol or objects files. Lanaguage is included in
+ /// case we need to filter results by language at a later date. The
+ /// "m_name_type_mask" member variable tells us what kinds of names we
+ /// are looking for and can help us prune out unwanted results.
+ ///
+ /// Function lookups are done in Module.cpp, ModuleList.cpp and in
+ /// BreakpointResolverName.cpp and they all now use this class to do
+ /// lookups correctly.
+ //----------------------------------------------------------------------
+ class LookupInfo {
+ public:
+ LookupInfo()
+ : m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown),
+ m_name_type_mask(0), m_match_name_after_lookup(false) {}
+
+ LookupInfo(const ConstString &name, uint32_t name_type_mask,
+ lldb::LanguageType language);
+
+ const ConstString &GetName() const { return m_name; }
+
+ void SetName(const ConstString &name) { m_name = name; }
+
+ const ConstString &GetLookupName() const { return m_lookup_name; }
+
+ void SetLookupName(const ConstString &name) { m_lookup_name = name; }
+
+ uint32_t GetNameTypeMask() const { return m_name_type_mask; }
+
+ void SetNameTypeMask(uint32_t mask) { m_name_type_mask = mask; }
+
+ void Prune(SymbolContextList &sc_list, size_t start_idx) const;
+
+ protected:
+ ConstString m_name; ///< What the user originally typed
+ ConstString m_lookup_name; ///< The actual name will lookup when calling in
+ ///the object or symbol file
+ lldb::LanguageType
+ m_language; ///< Limit matches to only be for this language
+ uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType
+ ///that indicate what kind of names we are
+ ///looking for
+ bool m_match_name_after_lookup; ///< If \b true, then demangled names that
+ ///match will need to contain "m_name" in
+ ///order to be considered a match
+ };
protected:
- //------------------------------------------------------------------
- // Member Variables
- //------------------------------------------------------------------
- mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
- TimeValue m_mod_time; ///< The modification time for this module when it was created.
- ArchSpec m_arch; ///< The architecture for this module.
- UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
- FileSpec m_file; ///< The file representation on disk for this module (if there is one).
- FileSpec m_platform_file;///< The path to the module on the platform on which it is being debugged
- FileSpec m_remote_install_file; ///< If set when debugging on remote platforms, this module will be installed at this location
- FileSpec m_symfile_spec; ///< If this path is valid, then this is the file that _will_ be used as the symbol file for this module
- ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file.
- uint64_t m_object_offset;
- TimeValue m_object_mod_time;
- lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file parser for this module as it may or may not be shared with the SymbolFile
- lldb::SymbolVendorUP m_symfile_ap; ///< A pointer to the symbol vendor for this module.
- std::vector<lldb::SymbolVendorUP> m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,
- ///< we need to keep all old symbol files around in case anyone has type references to them
- TypeSystemMap m_type_system_map; ///< A map of any type systems associated with this module
- PathMappingList m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are
- lldb::SectionListUP m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info
-
- std::atomic<bool> m_did_load_objfile;
- std::atomic<bool> m_did_load_symbol_vendor;
- std::atomic<bool> m_did_parse_uuid;
- mutable bool m_file_has_changed:1,
- m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.
-
- //------------------------------------------------------------------
- /// Resolve a file or load virtual address.
- ///
- /// Tries to resolve \a vm_addr as a file address (if \a
- /// vm_addr_is_file_addr is true) or as a load address if \a
- /// vm_addr_is_file_addr is false) in the symbol vendor.
- /// \a resolve_scope indicates what clients wish to resolve
- /// and can be used to limit the scope of what is parsed.
- ///
- /// @param[in] vm_addr
- /// The load virtual address to resolve.
- ///
- /// @param[in] vm_addr_is_file_addr
- /// If \b true, \a vm_addr is a file address, else \a vm_addr
- /// if a load address.
- ///
- /// @param[in] resolve_scope
- /// The scope that should be resolved (see
- /// SymbolContext::Scope).
- ///
- /// @param[out] so_addr
- /// The section offset based address that got resolved if
- /// any bits are returned.
- ///
- /// @param[out] sc
- // The symbol context that has objects filled in. Each bit
- /// in the \a resolve_scope pertains to a member in the \a sc.
- ///
- /// @return
- /// A integer that contains SymbolContext::Scope bits set for
- /// each item that was successfully resolved.
- ///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForAddress (lldb::addr_t vm_addr,
- bool vm_addr_is_file_addr,
- uint32_t resolve_scope,
- Address& so_addr,
- SymbolContext& sc);
-
- void
- SymbolIndicesToSymbolContextList (Symtab *symtab,
- std::vector<uint32_t> &symbol_indexes,
- SymbolContextList &sc_list);
-
- bool
- SetArchitecture (const ArchSpec &new_arch);
-
- SectionList *
- GetUnifiedSectionList();
-
- friend class ModuleList;
- friend class ObjectFile;
- friend class SymbolFile;
+ //------------------------------------------------------------------
+ // Member Variables
+ //------------------------------------------------------------------
+ mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
+ ///in multi-threaded environments.
+ TimeValue m_mod_time; ///< The modification time for this module when it was
+ ///created.
+ ArchSpec m_arch; ///< The architecture for this module.
+ UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
+ ///match it up to debug symbols.
+ FileSpec m_file; ///< The file representation on disk for this module (if
+ ///there is one).
+ FileSpec m_platform_file; ///< The path to the module on the platform on which
+ ///it is being debugged
+ FileSpec m_remote_install_file; ///< If set when debugging on remote
+ ///platforms, this module will be installed at
+ ///this location
+ FileSpec m_symfile_spec; ///< If this path is valid, then this is the file
+ ///that _will_ be used as the symbol file for this
+ ///module
+ ConstString m_object_name; ///< The name an object within this module that is
+ ///selected, or empty of the module is represented
+ ///by \a m_file.
+ uint64_t m_object_offset;
+ TimeValue m_object_mod_time;
+ lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
+ ///parser for this module as it may or may
+ ///not be shared with the SymbolFile
+ lldb::SymbolVendorUP
+ m_symfile_ap; ///< A pointer to the symbol vendor for this module.
+ std::vector<lldb::SymbolVendorUP>
+ m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
+ ///changes the symbol file,
+ ///< we need to keep all old symbol files around in case anyone has type
+ ///references to them
+ TypeSystemMap m_type_system_map; ///< A map of any type systems associated
+ ///with this module
+ PathMappingList m_source_mappings; ///< Module specific source remappings for
+ ///when you have debug info for a module
+ ///that doesn't match where the sources
+ ///currently are
+ lldb::SectionListUP m_sections_ap; ///< Unified section list for module that
+ ///is used by the ObjectFile and and
+ ///ObjectFile instances for the debug info
+
+ std::atomic<bool> m_did_load_objfile;
+ std::atomic<bool> m_did_load_symbol_vendor;
+ std::atomic<bool> m_did_parse_uuid;
+ mutable bool m_file_has_changed : 1,
+ m_first_file_changed_log : 1; /// See if the module was modified after it
+ /// was initially opened.
+
+ //------------------------------------------------------------------
+ /// Resolve a file or load virtual address.
+ ///
+ /// Tries to resolve \a vm_addr as a file address (if \a
+ /// vm_addr_is_file_addr is true) or as a load address if \a
+ /// vm_addr_is_file_addr is false) in the symbol vendor.
+ /// \a resolve_scope indicates what clients wish to resolve
+ /// and can be used to limit the scope of what is parsed.
+ ///
+ /// @param[in] vm_addr
+ /// The load virtual address to resolve.
+ ///
+ /// @param[in] vm_addr_is_file_addr
+ /// If \b true, \a vm_addr is a file address, else \a vm_addr
+ /// if a load address.
+ ///
+ /// @param[in] resolve_scope
+ /// The scope that should be resolved (see
+ /// SymbolContext::Scope).
+ ///
+ /// @param[out] so_addr
+ /// The section offset based address that got resolved if
+ /// any bits are returned.
+ ///
+ /// @param[out] sc
+ // The symbol context that has objects filled in. Each bit
+ /// in the \a resolve_scope pertains to a member in the \a sc.
+ ///
+ /// @return
+ /// A integer that contains SymbolContext::Scope bits set for
+ /// each item that was successfully resolved.
+ ///
+ /// @see SymbolContext::Scope
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr,
+ bool vm_addr_is_file_addr,
+ uint32_t resolve_scope,
+ Address &so_addr, SymbolContext &sc);
+
+ void SymbolIndicesToSymbolContextList(Symtab *symtab,
+ std::vector<uint32_t> &symbol_indexes,
+ SymbolContextList &sc_list);
+
+ bool SetArchitecture(const ArchSpec &new_arch);
+
+ SectionList *GetUnifiedSectionList();
+
+ friend class ModuleList;
+ friend class ObjectFile;
+ friend class SymbolFile;
private:
- Module (); // Only used internally by CreateJITModule ()
-
- size_t
- FindTypes_Impl (const SymbolContext& sc,
- const ConstString &name,
- const CompilerDeclContext *parent_decl_ctx,
- bool append,
- size_t max_matches,
- llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeMap& types);
+ Module(); // Only used internally by CreateJITModule ()
+
+ size_t FindTypes_Impl(
+ const SymbolContext &sc, const ConstString &name,
+ const CompilerDeclContext *parent_decl_ctx, bool append,
+ size_t max_matches,
+ llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
+ TypeMap &types);
- DISALLOW_COPY_AND_ASSIGN (Module);
+ DISALLOW_COPY_AND_ASSIGN(Module);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ModuleChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleChild.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleChild.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleChild.h Tue Sep 6 15:57:50 2016
@@ -19,72 +19,67 @@ namespace lldb_private {
/// @brief A mix in class that contains a pointer back to the module
/// that owns the object which inherits from it.
//----------------------------------------------------------------------
-class ModuleChild
-{
+class ModuleChild {
public:
- //------------------------------------------------------------------
- /// Construct with owning module.
- ///
- /// @param[in] module
- /// The module that owns the object that inherits from this
- /// class.
- //------------------------------------------------------------------
- ModuleChild (const lldb::ModuleSP &module_sp);
-
- //------------------------------------------------------------------
- /// Copy constructor.
- ///
- /// @param[in] rhs
- /// A const ModuleChild class reference to copy.
- //------------------------------------------------------------------
- ModuleChild (const ModuleChild& rhs);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~ModuleChild();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// @param[in] rhs
- /// A const ModuleChild class reference to copy.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const ModuleChild&
- operator= (const ModuleChild& rhs);
-
- //------------------------------------------------------------------
- /// Get const accessor for the module pointer.
- ///
- /// @return
- /// A const pointer to the module that owns the object that
- /// inherits from this class.
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModule () const;
-
- //------------------------------------------------------------------
- /// Set accessor for the module pointer.
- ///
- /// @param[in] module
- /// A new module that owns the object that inherits from this
- /// class.
- //------------------------------------------------------------------
- void
- SetModule (const lldb::ModuleSP &module_sp);
+ //------------------------------------------------------------------
+ /// Construct with owning module.
+ ///
+ /// @param[in] module
+ /// The module that owns the object that inherits from this
+ /// class.
+ //------------------------------------------------------------------
+ ModuleChild(const lldb::ModuleSP &module_sp);
+
+ //------------------------------------------------------------------
+ /// Copy constructor.
+ ///
+ /// @param[in] rhs
+ /// A const ModuleChild class reference to copy.
+ //------------------------------------------------------------------
+ ModuleChild(const ModuleChild &rhs);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~ModuleChild();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// @param[in] rhs
+ /// A const ModuleChild class reference to copy.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const ModuleChild &operator=(const ModuleChild &rhs);
+
+ //------------------------------------------------------------------
+ /// Get const accessor for the module pointer.
+ ///
+ /// @return
+ /// A const pointer to the module that owns the object that
+ /// inherits from this class.
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModule() const;
+
+ //------------------------------------------------------------------
+ /// Set accessor for the module pointer.
+ ///
+ /// @param[in] module
+ /// A new module that owns the object that inherits from this
+ /// class.
+ //------------------------------------------------------------------
+ void SetModule(const lldb::ModuleSP &module_sp);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- lldb::ModuleWP m_module_wp; ///< The Module that owns the object that inherits
- ///< from this class.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ lldb::ModuleWP m_module_wp; ///< The Module that owns the object that inherits
+ ///< from this class.
};
} // namespace lldb_private
-
-#endif // liblldb_ModuleChild_h_
+#endif // liblldb_ModuleChild_h_
Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Tue Sep 6 15:57:50 2016
@@ -19,8 +19,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private {
@@ -32,585 +32,515 @@ namespace lldb_private {
/// Modules in the module collection class are stored as reference
/// counted shared pointers to Module objects.
//----------------------------------------------------------------------
-class ModuleList
-{
+class ModuleList {
public:
- class Notifier
- {
- public:
- virtual
- ~Notifier() = default;
-
- virtual void
- ModuleAdded (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0;
- virtual void
- ModuleRemoved (const ModuleList& module_list, const lldb::ModuleSP& module_sp) = 0;
- virtual void
- ModuleUpdated (const ModuleList& module_list, const lldb::ModuleSP& old_module_sp,
- const lldb::ModuleSP& new_module_sp) = 0;
- virtual void
- WillClearList (const ModuleList& module_list) = 0;
- };
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// Creates an empty list of Module objects.
- //------------------------------------------------------------------
- ModuleList ();
-
- //------------------------------------------------------------------
- /// Copy Constructor.
- ///
- /// Creates a new module list object with a copy of the modules from
- /// \a rhs.
- ///
- /// @param[in] rhs
- /// Another module list object.
- //------------------------------------------------------------------
- ModuleList (const ModuleList& rhs);
-
- ModuleList (ModuleList::Notifier* notifier);
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~ModuleList ();
-
- //------------------------------------------------------------------
- /// Assignment operator.
- ///
- /// Copies the module list from \a rhs into this list.
- ///
- /// @param[in] rhs
- /// Another module list object.
- ///
- /// @return
- /// A const reference to this object.
- //------------------------------------------------------------------
- const ModuleList&
- operator= (const ModuleList& rhs);
-
- //------------------------------------------------------------------
- /// Append a module to the module list.
- ///
- /// Appends the module to the collection.
- ///
- /// @param[in] module_sp
- /// A shared pointer to a module to add to this collection.
- //------------------------------------------------------------------
- void
- Append (const lldb::ModuleSP &module_sp);
-
- //------------------------------------------------------------------
- /// Append a module to the module list and remove any equivalent
- /// modules. Equivalent modules are ones whose file, platform file
- /// and architecture matches.
- ///
- /// Replaces the module to the collection.
- ///
- /// @param[in] module_sp
- /// A shared pointer to a module to replace in this collection.
- //------------------------------------------------------------------
- void
- ReplaceEquivalent (const lldb::ModuleSP &module_sp);
-
- bool
- AppendIfNeeded (const lldb::ModuleSP &module_sp);
-
- void
- Append (const ModuleList& module_list);
-
- bool
- AppendIfNeeded (const ModuleList& module_list);
-
- bool
- ReplaceModule (const lldb::ModuleSP &old_module_sp, const lldb::ModuleSP &new_module_sp);
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Clears the list of modules and releases a reference to each
- /// module object and if the reference count goes to zero, the
- /// module will be deleted.
- //------------------------------------------------------------------
- void
- Clear ();
-
- //------------------------------------------------------------------
- /// Clear the object's state.
- ///
- /// Clears the list of modules and releases a reference to each
- /// module object and if the reference count goes to zero, the
- /// module will be deleted. Also release all memory that might be
- /// held by any collection classes (like std::vector)
- //------------------------------------------------------------------
- void
- Destroy();
-
- //------------------------------------------------------------------
- /// Dump the description of each module contained in this list.
- ///
- /// Dump the description of each module contained in this list to
- /// the supplied stream \a s.
- ///
- /// @param[in] s
- /// The stream to which to dump the object description.
- ///
- /// @see Module::Dump(Stream *) const
- //------------------------------------------------------------------
- void
- Dump (Stream *s) const;
-
- void
- LogUUIDAndPaths (Log *log, const char *prefix_cstr);
-
- std::recursive_mutex &
- GetMutex() const
- {
- return m_modules_mutex;
- }
-
- size_t
- GetIndexForModule (const Module *module) const;
-
- //------------------------------------------------------------------
- /// Get the module shared pointer for the module at index \a idx.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A shared pointer to a Module which can contain NULL if
- /// \a idx is out of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModuleAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the module shared pointer for the module at index \a idx without
- /// acquiring the ModuleList mutex. This MUST already have been
- /// acquired with ModuleList::GetMutex and locked for this call to be safe.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A shared pointer to a Module which can contain NULL if
- /// \a idx is out of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- lldb::ModuleSP
- GetModuleAtIndexUnlocked (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the module pointer for the module at index \a idx.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A pointer to a Module which can by nullptr if \a idx is out
- /// of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- Module*
- GetModulePointerAtIndex (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Get the module pointer for the module at index \a idx without
- /// acquiring the ModuleList mutex. This MUST already have been
- /// acquired with ModuleList::GetMutex and locked for this call to be safe.
- ///
- /// @param[in] idx
- /// An index into this module collection.
- ///
- /// @return
- /// A pointer to a Module which can by nullptr if \a idx is out
- /// of range.
- ///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
- Module*
- GetModulePointerAtIndexUnlocked (size_t idx) const;
-
- //------------------------------------------------------------------
- /// Find compile units by partial or full path.
- ///
- /// Finds all compile units that match \a path in all of the modules
- /// and returns the results in \a sc_list.
- ///
- /// @param[in] path
- /// The name of the compile unit we are looking for.
- ///
- /// @param[in] append
- /// If \b true, then append any compile units that were found
- /// to \a sc_list. If \b false, then the \a sc_list is cleared
- /// and the contents of \a sc_list are replaced.
- ///
- /// @param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- ///
- /// @return
- /// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t
- FindCompileUnits (const FileSpec &path,
- bool append,
- SymbolContextList &sc_list) const;
-
- //------------------------------------------------------------------
- /// @see Module::FindFunctions ()
- //------------------------------------------------------------------
- size_t
- FindFunctions (const ConstString &name,
- uint32_t name_type_mask,
- bool include_symbols,
- bool include_inlines,
- bool append,
- SymbolContextList &sc_list) const;
-
- //------------------------------------------------------------------
- /// @see Module::FindFunctionSymbols ()
- //------------------------------------------------------------------
- size_t
- FindFunctionSymbols (const ConstString &name,
- uint32_t name_type_mask,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// @see Module::FindFunctions ()
- //------------------------------------------------------------------
- size_t
- FindFunctions(const RegularExpression &name,
- bool include_symbols,
- bool include_inlines,
- bool append,
- SymbolContextList& sc_list);
-
- //------------------------------------------------------------------
- /// Find global and static variables by name.
- ///
- /// @param[in] name
- /// The name of the global or static variable we are looking
- /// for.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const ConstString &name,
- bool append,
- size_t max_matches,
- VariableList& variable_list) const;
-
- //------------------------------------------------------------------
- /// Find global and static variables by regular expression.
- ///
- /// @param[in] regex
- /// A regular expression to use when matching the name.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] variable_list
- /// A list of variables that gets the matches appended to (if
- /// \a append it \b true), or replace (if \a append is \b false).
- ///
- /// @return
- /// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t
- FindGlobalVariables (const RegularExpression& regex,
- bool append,
- size_t max_matches,
- VariableList& variable_list) const;
-
- //------------------------------------------------------------------
- /// Finds the first module whose file specification matches \a
- /// file_spec.
- ///
- /// @param[in] file_spec_ptr
- /// A file specification object to match against the Module's
- /// file specifications. If \a file_spec does not have
- /// directory information, matches will occur by matching only
- /// the basename of any modules in this list. If this value is
- /// NULL, then file specifications won't be compared when
- /// searching for matching modules.
- ///
- /// @param[in] arch_ptr
- /// The architecture to search for if non-NULL. If this value
- /// is NULL no architecture matching will be performed.
- ///
- /// @param[in] uuid_ptr
- /// The uuid to search for if non-NULL. If this value is NULL
- /// no uuid matching will be performed.
- ///
- /// @param[in] object_name
- /// An optional object name that must match as well. This value
- /// can be NULL.
- ///
- /// @param[out] matching_module_list
- /// A module list that gets filled in with any modules that
- /// match the search criteria.
- ///
- /// @return
- /// The number of matching modules found by the search.
- //------------------------------------------------------------------
- size_t
- FindModules (const ModuleSpec &module_spec,
- ModuleList& matching_module_list) const;
-
- lldb::ModuleSP
- FindModule (const Module *module_ptr) const;
-
- //------------------------------------------------------------------
- // Find a module by UUID
- //
- // The UUID value for a module is extracted from the ObjectFile and
- // is the MD5 checksum, or a smarter object file equivalent, so
- // finding modules by UUID values is very efficient and accurate.
- //------------------------------------------------------------------
- lldb::ModuleSP
- FindModule (const UUID &uuid) const;
-
- lldb::ModuleSP
- FindFirstModule (const ModuleSpec &module_spec) const;
-
- size_t
- FindSymbolsWithNameAndType (const ConstString &name,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list,
- bool append = false) const;
-
- size_t
- FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
- lldb::SymbolType symbol_type,
- SymbolContextList &sc_list,
- bool append = false) const;
-
- //------------------------------------------------------------------
- /// Find types by name.
- ///
- /// @param[in] sc
- /// A symbol context that scopes where to extract a type list
- /// from.
- ///
- /// @param[in] name
- /// The name of the type we are looking for.
- ///
- /// @param[in] append
- /// If \b true, any matches will be appended to \a
- /// variable_list, else matches replace the contents of
- /// \a variable_list.
- ///
- /// @param[in] max_matches
- /// Allow the number of matches to be limited to \a
- /// max_matches. Specify UINT32_MAX to get all possible matches.
- ///
- /// @param[in] encoding
- /// Limit the search to specific types, or get all types if
- /// set to Type::invalid.
- ///
- /// @param[in] udt_name
- /// If the encoding is a user defined type, specify the name
- /// of the user defined type ("struct", "union", "class", etc).
- ///
- /// @param[out] type_list
- /// A type list gets populated with any matches.
- ///
- /// @return
- /// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t
- FindTypes (const SymbolContext& sc,
- const ConstString &name,
- bool name_is_fully_qualified,
- size_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeList& types) const;
-
- bool
- FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
-
-
- //------------------------------------------------------------------
- /// Find addresses by file/line
- ///
- /// @param[in] target_sp
- /// The target the addresses are desired for.
- ///
- /// @param[in] file
- /// Source file to locate.
- ///
- /// @param[in] line
- /// Source line to locate.
- ///
- /// @param[in] function
- /// Optional filter function. Addresses within this function will be
- /// added to the 'local' list. All others will be added to the 'extern' list.
- ///
- /// @param[out] output_local
- /// All matching addresses within 'function'
- ///
- /// @param[out] output_extern
- /// All matching addresses not within 'function'
- void FindAddressesForLine (const lldb::TargetSP target_sp,
- const FileSpec &file, uint32_t line,
- Function *function,
- std::vector<Address> &output_local, std::vector<Address> &output_extern);
-
-
- bool
- Remove (const lldb::ModuleSP &module_sp);
-
- size_t
- Remove (ModuleList &module_list);
-
- bool
- RemoveIfOrphaned (const Module *module_ptr);
-
- size_t
- RemoveOrphans (bool mandatory);
-
- bool
- ResolveFileAddress (lldb::addr_t vm_addr,
- Address& so_addr) const;
-
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextForAddress (const Address &,uint32_t,SymbolContext&)
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForAddress (const Address& so_addr,
- uint32_t resolve_scope,
- SymbolContext& sc) const;
-
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextForFilePath (const char *,uint32_t,bool,uint32_t,SymbolContextList&)
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextForFilePath (const char *file_path,
- uint32_t line,
- bool check_inlines,
- uint32_t resolve_scope,
- SymbolContextList& sc_list) const;
-
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec &,uint32_t,bool,uint32_t,SymbolContextList&)
- //------------------------------------------------------------------
- uint32_t
- ResolveSymbolContextsForFileSpec (const FileSpec &file_spec,
- uint32_t line,
- bool check_inlines,
- uint32_t resolve_scope,
- SymbolContextList& sc_list) const;
-
- //------------------------------------------------------------------
- /// Gets the size of the module list.
- ///
- /// @return
- /// The number of modules in the module list.
- //------------------------------------------------------------------
- size_t
- GetSize () const;
-
- bool
- LoadScriptingResourcesInTarget(Target *target,
- std::list<Error>& errors,
- Stream* feedback_stream = nullptr,
- bool continue_on_error = true);
-
- static bool
- ModuleIsInCache (const Module *module_ptr);
-
- static Error
- GetSharedModule (const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr,
- bool always_create = false);
-
- static bool
- RemoveSharedModule (lldb::ModuleSP &module_sp);
-
- static size_t
- FindSharedModules (const ModuleSpec &module_spec,
- ModuleList &matching_module_list);
-
- static size_t
- RemoveOrphanSharedModules (bool mandatory);
-
- static bool
- RemoveSharedModuleIfOrphaned (const Module *module_ptr);
+ class Notifier {
+ public:
+ virtual ~Notifier() = default;
+
+ virtual void ModuleAdded(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) = 0;
+ virtual void ModuleRemoved(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) = 0;
+ virtual void ModuleUpdated(const ModuleList &module_list,
+ const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp) = 0;
+ virtual void WillClearList(const ModuleList &module_list) = 0;
+ };
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// Creates an empty list of Module objects.
+ //------------------------------------------------------------------
+ ModuleList();
+
+ //------------------------------------------------------------------
+ /// Copy Constructor.
+ ///
+ /// Creates a new module list object with a copy of the modules from
+ /// \a rhs.
+ ///
+ /// @param[in] rhs
+ /// Another module list object.
+ //------------------------------------------------------------------
+ ModuleList(const ModuleList &rhs);
+
+ ModuleList(ModuleList::Notifier *notifier);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~ModuleList();
+
+ //------------------------------------------------------------------
+ /// Assignment operator.
+ ///
+ /// Copies the module list from \a rhs into this list.
+ ///
+ /// @param[in] rhs
+ /// Another module list object.
+ ///
+ /// @return
+ /// A const reference to this object.
+ //------------------------------------------------------------------
+ const ModuleList &operator=(const ModuleList &rhs);
+
+ //------------------------------------------------------------------
+ /// Append a module to the module list.
+ ///
+ /// Appends the module to the collection.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer to a module to add to this collection.
+ //------------------------------------------------------------------
+ void Append(const lldb::ModuleSP &module_sp);
+
+ //------------------------------------------------------------------
+ /// Append a module to the module list and remove any equivalent
+ /// modules. Equivalent modules are ones whose file, platform file
+ /// and architecture matches.
+ ///
+ /// Replaces the module to the collection.
+ ///
+ /// @param[in] module_sp
+ /// A shared pointer to a module to replace in this collection.
+ //------------------------------------------------------------------
+ void ReplaceEquivalent(const lldb::ModuleSP &module_sp);
+
+ bool AppendIfNeeded(const lldb::ModuleSP &module_sp);
+
+ void Append(const ModuleList &module_list);
+
+ bool AppendIfNeeded(const ModuleList &module_list);
+
+ bool ReplaceModule(const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp);
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Clears the list of modules and releases a reference to each
+ /// module object and if the reference count goes to zero, the
+ /// module will be deleted.
+ //------------------------------------------------------------------
+ void Clear();
+
+ //------------------------------------------------------------------
+ /// Clear the object's state.
+ ///
+ /// Clears the list of modules and releases a reference to each
+ /// module object and if the reference count goes to zero, the
+ /// module will be deleted. Also release all memory that might be
+ /// held by any collection classes (like std::vector)
+ //------------------------------------------------------------------
+ void Destroy();
+
+ //------------------------------------------------------------------
+ /// Dump the description of each module contained in this list.
+ ///
+ /// Dump the description of each module contained in this list to
+ /// the supplied stream \a s.
+ ///
+ /// @param[in] s
+ /// The stream to which to dump the object description.
+ ///
+ /// @see Module::Dump(Stream *) const
+ //------------------------------------------------------------------
+ void Dump(Stream *s) const;
+
+ void LogUUIDAndPaths(Log *log, const char *prefix_cstr);
+
+ std::recursive_mutex &GetMutex() const { return m_modules_mutex; }
+
+ size_t GetIndexForModule(const Module *module) const;
+
+ //------------------------------------------------------------------
+ /// Get the module shared pointer for the module at index \a idx.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A shared pointer to a Module which can contain NULL if
+ /// \a idx is out of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModuleAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the module shared pointer for the module at index \a idx without
+ /// acquiring the ModuleList mutex. This MUST already have been
+ /// acquired with ModuleList::GetMutex and locked for this call to be safe.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A shared pointer to a Module which can contain NULL if
+ /// \a idx is out of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the module pointer for the module at index \a idx.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A pointer to a Module which can by nullptr if \a idx is out
+ /// of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ Module *GetModulePointerAtIndex(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Get the module pointer for the module at index \a idx without
+ /// acquiring the ModuleList mutex. This MUST already have been
+ /// acquired with ModuleList::GetMutex and locked for this call to be safe.
+ ///
+ /// @param[in] idx
+ /// An index into this module collection.
+ ///
+ /// @return
+ /// A pointer to a Module which can by nullptr if \a idx is out
+ /// of range.
+ ///
+ /// @see ModuleList::GetSize()
+ //------------------------------------------------------------------
+ Module *GetModulePointerAtIndexUnlocked(size_t idx) const;
+
+ //------------------------------------------------------------------
+ /// Find compile units by partial or full path.
+ ///
+ /// Finds all compile units that match \a path in all of the modules
+ /// and returns the results in \a sc_list.
+ ///
+ /// @param[in] path
+ /// The name of the compile unit we are looking for.
+ ///
+ /// @param[in] append
+ /// If \b true, then append any compile units that were found
+ /// to \a sc_list. If \b false, then the \a sc_list is cleared
+ /// and the contents of \a sc_list are replaced.
+ ///
+ /// @param[out] sc_list
+ /// A symbol context list that gets filled in with all of the
+ /// matches.
+ ///
+ /// @return
+ /// The number of matches added to \a sc_list.
+ //------------------------------------------------------------------
+ size_t FindCompileUnits(const FileSpec &path, bool append,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// @see Module::FindFunctions ()
+ //------------------------------------------------------------------
+ size_t FindFunctions(const ConstString &name, uint32_t name_type_mask,
+ bool include_symbols, bool include_inlines, bool append,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// @see Module::FindFunctionSymbols ()
+ //------------------------------------------------------------------
+ size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// @see Module::FindFunctions ()
+ //------------------------------------------------------------------
+ size_t FindFunctions(const RegularExpression &name, bool include_symbols,
+ bool include_inlines, bool append,
+ SymbolContextList &sc_list);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by name.
+ ///
+ /// @param[in] name
+ /// The name of the global or static variable we are looking
+ /// for.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const ConstString &name, bool append,
+ size_t max_matches,
+ VariableList &variable_list) const;
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by regular expression.
+ ///
+ /// @param[in] regex
+ /// A regular expression to use when matching the name.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] variable_list
+ /// A list of variables that gets the matches appended to (if
+ /// \a append it \b true), or replace (if \a append is \b false).
+ ///
+ /// @return
+ /// The number of matches added to \a variable_list.
+ //------------------------------------------------------------------
+ size_t FindGlobalVariables(const RegularExpression ®ex, bool append,
+ size_t max_matches,
+ VariableList &variable_list) const;
+
+ //------------------------------------------------------------------
+ /// Finds the first module whose file specification matches \a
+ /// file_spec.
+ ///
+ /// @param[in] file_spec_ptr
+ /// A file specification object to match against the Module's
+ /// file specifications. If \a file_spec does not have
+ /// directory information, matches will occur by matching only
+ /// the basename of any modules in this list. If this value is
+ /// NULL, then file specifications won't be compared when
+ /// searching for matching modules.
+ ///
+ /// @param[in] arch_ptr
+ /// The architecture to search for if non-NULL. If this value
+ /// is NULL no architecture matching will be performed.
+ ///
+ /// @param[in] uuid_ptr
+ /// The uuid to search for if non-NULL. If this value is NULL
+ /// no uuid matching will be performed.
+ ///
+ /// @param[in] object_name
+ /// An optional object name that must match as well. This value
+ /// can be NULL.
+ ///
+ /// @param[out] matching_module_list
+ /// A module list that gets filled in with any modules that
+ /// match the search criteria.
+ ///
+ /// @return
+ /// The number of matching modules found by the search.
+ //------------------------------------------------------------------
+ size_t FindModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list) const;
+
+ lldb::ModuleSP FindModule(const Module *module_ptr) const;
+
+ //------------------------------------------------------------------
+ // Find a module by UUID
+ //
+ // The UUID value for a module is extracted from the ObjectFile and
+ // is the MD5 checksum, or a smarter object file equivalent, so
+ // finding modules by UUID values is very efficient and accurate.
+ //------------------------------------------------------------------
+ lldb::ModuleSP FindModule(const UUID &uuid) const;
+
+ lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const;
+
+ size_t FindSymbolsWithNameAndType(const ConstString &name,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list,
+ bool append = false) const;
+
+ size_t FindSymbolsMatchingRegExAndType(const RegularExpression ®ex,
+ lldb::SymbolType symbol_type,
+ SymbolContextList &sc_list,
+ bool append = false) const;
+
+ //------------------------------------------------------------------
+ /// Find types by name.
+ ///
+ /// @param[in] sc
+ /// A symbol context that scopes where to extract a type list
+ /// from.
+ ///
+ /// @param[in] name
+ /// The name of the type we are looking for.
+ ///
+ /// @param[in] append
+ /// If \b true, any matches will be appended to \a
+ /// variable_list, else matches replace the contents of
+ /// \a variable_list.
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a
+ /// max_matches. Specify UINT32_MAX to get all possible matches.
+ ///
+ /// @param[in] encoding
+ /// Limit the search to specific types, or get all types if
+ /// set to Type::invalid.
+ ///
+ /// @param[in] udt_name
+ /// If the encoding is a user defined type, specify the name
+ /// of the user defined type ("struct", "union", "class", etc).
+ ///
+ /// @param[out] type_list
+ /// A type list gets populated with any matches.
+ ///
+ /// @return
+ /// The number of matches added to \a type_list.
+ //------------------------------------------------------------------
+ size_t FindTypes(const SymbolContext &sc, const ConstString &name,
+ bool name_is_fully_qualified, size_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeList &types) const;
+
+ bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
+
+ //------------------------------------------------------------------
+ /// Find addresses by file/line
+ ///
+ /// @param[in] target_sp
+ /// The target the addresses are desired for.
+ ///
+ /// @param[in] file
+ /// Source file to locate.
+ ///
+ /// @param[in] line
+ /// Source line to locate.
+ ///
+ /// @param[in] function
+ /// Optional filter function. Addresses within this function will be
+ /// added to the 'local' list. All others will be added to the 'extern'
+ /// list.
+ ///
+ /// @param[out] output_local
+ /// All matching addresses within 'function'
+ ///
+ /// @param[out] output_extern
+ /// All matching addresses not within 'function'
+ void FindAddressesForLine(const lldb::TargetSP target_sp,
+ const FileSpec &file, uint32_t line,
+ Function *function,
+ std::vector<Address> &output_local,
+ std::vector<Address> &output_extern);
+
+ bool Remove(const lldb::ModuleSP &module_sp);
+
+ size_t Remove(ModuleList &module_list);
+
+ bool RemoveIfOrphaned(const Module *module_ptr);
+
+ size_t RemoveOrphans(bool mandatory);
+
+ bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc Module::ResolveSymbolContextForAddress (const Address
+ /// &,uint32_t,SymbolContext&)
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForAddress(const Address &so_addr,
+ uint32_t resolve_scope,
+ SymbolContext &sc) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc Module::ResolveSymbolContextForFilePath (const char
+ /// *,uint32_t,bool,uint32_t,SymbolContextList&)
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line,
+ bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec
+ /// &,uint32_t,bool,uint32_t,SymbolContextList&)
+ //------------------------------------------------------------------
+ uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ uint32_t resolve_scope,
+ SymbolContextList &sc_list) const;
+
+ //------------------------------------------------------------------
+ /// Gets the size of the module list.
+ ///
+ /// @return
+ /// The number of modules in the module list.
+ //------------------------------------------------------------------
+ size_t GetSize() const;
+
+ bool LoadScriptingResourcesInTarget(Target *target, std::list<Error> &errors,
+ Stream *feedback_stream = nullptr,
+ bool continue_on_error = true);
+
+ static bool ModuleIsInCache(const Module *module_ptr);
+
+ static Error GetSharedModule(const ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr,
+ lldb::ModuleSP *old_module_sp_ptr,
+ bool *did_create_ptr,
+ bool always_create = false);
+
+ static bool RemoveSharedModule(lldb::ModuleSP &module_sp);
+
+ static size_t FindSharedModules(const ModuleSpec &module_spec,
+ ModuleList &matching_module_list);
+
+ static size_t RemoveOrphanSharedModules(bool mandatory);
- void
- ForEach (std::function <bool (const lldb::ModuleSP &module_sp)> const &callback) const;
+ static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr);
+
+ void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const
+ &callback) const;
protected:
- //------------------------------------------------------------------
- // Class typedefs.
- //------------------------------------------------------------------
- typedef std::vector<lldb::ModuleSP> collection; ///< The module collection type.
-
- void
- AppendImpl (const lldb::ModuleSP &module_sp, bool use_notifier = true);
-
- bool
- RemoveImpl (const lldb::ModuleSP &module_sp, bool use_notifier = true);
-
- collection::iterator
- RemoveImpl (collection::iterator pos, bool use_notifier = true);
-
- void
- ClearImpl (bool use_notifier = true);
-
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- collection m_modules; ///< The collection of modules.
- mutable std::recursive_mutex m_modules_mutex;
+ //------------------------------------------------------------------
+ // Class typedefs.
+ //------------------------------------------------------------------
+ typedef std::vector<lldb::ModuleSP>
+ collection; ///< The module collection type.
+
+ void AppendImpl(const lldb::ModuleSP &module_sp, bool use_notifier = true);
+
+ bool RemoveImpl(const lldb::ModuleSP &module_sp, bool use_notifier = true);
+
+ collection::iterator RemoveImpl(collection::iterator pos,
+ bool use_notifier = true);
+
+ void ClearImpl(bool use_notifier = true);
+
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ collection m_modules; ///< The collection of modules.
+ mutable std::recursive_mutex m_modules_mutex;
+
+ Notifier *m_notifier;
- Notifier* m_notifier;
-
public:
- typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter, std::recursive_mutex> ModuleIterable;
- ModuleIterable
- Modules()
- {
- return ModuleIterable(m_modules, GetMutex());
- }
-
- typedef AdaptedIterable<collection, lldb::ModuleSP, vector_adapter> ModuleIterableNoLocking;
- ModuleIterableNoLocking
- ModulesNoLocking ()
- {
- return ModuleIterableNoLocking(m_modules);
- }
+ typedef LockingAdaptedIterable<collection, lldb::ModuleSP, vector_adapter,
+ std::recursive_mutex>
+ ModuleIterable;
+ ModuleIterable Modules() { return ModuleIterable(m_modules, GetMutex()); }
+
+ typedef AdaptedIterable<collection, lldb::ModuleSP, vector_adapter>
+ ModuleIterableNoLocking;
+ ModuleIterableNoLocking ModulesNoLocking() {
+ return ModuleIterableNoLocking(m_modules);
+ }
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ModuleSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleSpec.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleSpec.h Tue Sep 6 15:57:50 2016
@@ -25,575 +25,397 @@
namespace lldb_private {
-class ModuleSpec
-{
+class ModuleSpec {
public:
- ModuleSpec () :
- m_file (),
- m_platform_file (),
- m_symbol_file (),
- m_arch (),
- m_uuid (),
- m_object_name (),
- m_object_offset (0),
- m_object_size (0),
- m_object_mod_time (),
- m_source_mappings ()
- {
- }
-
- ModuleSpec (const FileSpec &file_spec) :
- m_file (file_spec),
- m_platform_file (),
- m_symbol_file (),
- m_arch (),
- m_uuid (),
- m_object_name (),
- m_object_offset (0),
- m_object_size (file_spec.GetByteSize ()),
- m_object_mod_time (),
- m_source_mappings ()
- {
- }
-
- ModuleSpec (const FileSpec &file_spec, const ArchSpec &arch) :
- m_file (file_spec),
- m_platform_file (),
- m_symbol_file (),
- m_arch (arch),
- m_uuid (),
- m_object_name (),
- m_object_offset (0),
- m_object_size (file_spec.GetByteSize ()),
- m_object_mod_time (),
- m_source_mappings ()
- {
- }
-
- ModuleSpec (const ModuleSpec &rhs) :
- m_file (rhs.m_file),
- m_platform_file (rhs.m_platform_file),
- m_symbol_file (rhs.m_symbol_file),
- m_arch (rhs.m_arch),
- m_uuid (rhs.m_uuid),
- m_object_name (rhs.m_object_name),
- m_object_offset (rhs.m_object_offset),
- m_object_size (rhs.m_object_size),
- m_object_mod_time (rhs.m_object_mod_time),
- m_source_mappings (rhs.m_source_mappings)
- {
- }
-
- ModuleSpec &
- operator = (const ModuleSpec &rhs)
- {
- if (this != &rhs)
- {
- m_file = rhs.m_file;
- m_platform_file = rhs.m_platform_file;
- m_symbol_file = rhs.m_symbol_file;
- m_arch = rhs.m_arch;
- m_uuid = rhs.m_uuid;
- m_object_name = rhs.m_object_name;
- m_object_offset = rhs.m_object_offset;
- m_object_size = rhs.m_object_size;
- m_object_mod_time = rhs.m_object_mod_time;
- m_source_mappings = rhs.m_source_mappings;
- }
- return *this;
+ ModuleSpec()
+ : m_file(), m_platform_file(), m_symbol_file(), m_arch(), m_uuid(),
+ m_object_name(), m_object_offset(0), m_object_size(0),
+ m_object_mod_time(), m_source_mappings() {}
+
+ ModuleSpec(const FileSpec &file_spec)
+ : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(),
+ m_uuid(), m_object_name(), m_object_offset(0),
+ m_object_size(file_spec.GetByteSize()), m_object_mod_time(),
+ m_source_mappings() {}
+
+ ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch)
+ : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch),
+ m_uuid(), m_object_name(), m_object_offset(0),
+ m_object_size(file_spec.GetByteSize()), m_object_mod_time(),
+ m_source_mappings() {}
+
+ ModuleSpec(const ModuleSpec &rhs)
+ : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file),
+ m_symbol_file(rhs.m_symbol_file), m_arch(rhs.m_arch),
+ m_uuid(rhs.m_uuid), m_object_name(rhs.m_object_name),
+ m_object_offset(rhs.m_object_offset), m_object_size(rhs.m_object_size),
+ m_object_mod_time(rhs.m_object_mod_time),
+ m_source_mappings(rhs.m_source_mappings) {}
+
+ ModuleSpec &operator=(const ModuleSpec &rhs) {
+ if (this != &rhs) {
+ m_file = rhs.m_file;
+ m_platform_file = rhs.m_platform_file;
+ m_symbol_file = rhs.m_symbol_file;
+ m_arch = rhs.m_arch;
+ m_uuid = rhs.m_uuid;
+ m_object_name = rhs.m_object_name;
+ m_object_offset = rhs.m_object_offset;
+ m_object_size = rhs.m_object_size;
+ m_object_mod_time = rhs.m_object_mod_time;
+ m_source_mappings = rhs.m_source_mappings;
+ }
+ return *this;
+ }
+
+ FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); }
+
+ const FileSpec *GetFileSpecPtr() const {
+ return (m_file ? &m_file : nullptr);
+ }
+
+ FileSpec &GetFileSpec() { return m_file; }
+
+ const FileSpec &GetFileSpec() const { return m_file; }
+
+ FileSpec *GetPlatformFileSpecPtr() {
+ return (m_platform_file ? &m_platform_file : nullptr);
+ }
+
+ const FileSpec *GetPlatformFileSpecPtr() const {
+ return (m_platform_file ? &m_platform_file : nullptr);
+ }
+
+ FileSpec &GetPlatformFileSpec() { return m_platform_file; }
+
+ const FileSpec &GetPlatformFileSpec() const { return m_platform_file; }
+
+ FileSpec *GetSymbolFileSpecPtr() {
+ return (m_symbol_file ? &m_symbol_file : nullptr);
+ }
+
+ const FileSpec *GetSymbolFileSpecPtr() const {
+ return (m_symbol_file ? &m_symbol_file : nullptr);
+ }
+
+ FileSpec &GetSymbolFileSpec() { return m_symbol_file; }
+
+ const FileSpec &GetSymbolFileSpec() const { return m_symbol_file; }
+
+ ArchSpec *GetArchitecturePtr() {
+ return (m_arch.IsValid() ? &m_arch : nullptr);
+ }
+
+ const ArchSpec *GetArchitecturePtr() const {
+ return (m_arch.IsValid() ? &m_arch : nullptr);
+ }
+
+ ArchSpec &GetArchitecture() { return m_arch; }
+
+ const ArchSpec &GetArchitecture() const { return m_arch; }
+
+ UUID *GetUUIDPtr() { return (m_uuid.IsValid() ? &m_uuid : nullptr); }
+
+ const UUID *GetUUIDPtr() const {
+ return (m_uuid.IsValid() ? &m_uuid : nullptr);
+ }
+
+ UUID &GetUUID() { return m_uuid; }
+
+ const UUID &GetUUID() const { return m_uuid; }
+
+ ConstString &GetObjectName() { return m_object_name; }
+
+ const ConstString &GetObjectName() const { return m_object_name; }
+
+ uint64_t GetObjectOffset() const { return m_object_offset; }
+
+ void SetObjectOffset(uint64_t object_offset) {
+ m_object_offset = object_offset;
+ }
+
+ uint64_t GetObjectSize() const { return m_object_size; }
+
+ void SetObjectSize(uint64_t object_size) { m_object_size = object_size; }
+
+ TimeValue &GetObjectModificationTime() { return m_object_mod_time; }
+
+ const TimeValue &GetObjectModificationTime() const {
+ return m_object_mod_time;
+ }
+
+ PathMappingList &GetSourceMappingList() const { return m_source_mappings; }
+
+ void Clear() {
+ m_file.Clear();
+ m_platform_file.Clear();
+ m_symbol_file.Clear();
+ m_arch.Clear();
+ m_uuid.Clear();
+ m_object_name.Clear();
+ m_object_offset = 0;
+ m_object_size = 0;
+ m_source_mappings.Clear(false);
+ m_object_mod_time.Clear();
+ }
+
+ explicit operator bool() const {
+ if (m_file)
+ return true;
+ if (m_platform_file)
+ return true;
+ if (m_symbol_file)
+ return true;
+ if (m_arch.IsValid())
+ return true;
+ if (m_uuid.IsValid())
+ return true;
+ if (m_object_name)
+ return true;
+ if (m_object_size)
+ return true;
+ if (m_object_mod_time.IsValid())
+ return true;
+ return false;
+ }
+
+ void Dump(Stream &strm) const {
+ bool dumped_something = false;
+ if (m_file) {
+ strm.PutCString("file = '");
+ strm << m_file;
+ strm.PutCString("'");
+ dumped_something = true;
+ }
+ if (m_platform_file) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.PutCString("platform_file = '");
+ strm << m_platform_file;
+ strm.PutCString("'");
+ dumped_something = true;
+ }
+ if (m_symbol_file) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.PutCString("symbol_file = '");
+ strm << m_symbol_file;
+ strm.PutCString("'");
+ dumped_something = true;
+ }
+ if (m_arch.IsValid()) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("arch = ");
+ m_arch.DumpTriple(strm);
+ dumped_something = true;
+ }
+ if (m_uuid.IsValid()) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.PutCString("uuid = ");
+ m_uuid.Dump(&strm);
+ dumped_something = true;
+ }
+ if (m_object_name) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_name = %s", m_object_name.GetCString());
+ dumped_something = true;
+ }
+ if (m_object_offset > 0) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_offset = %" PRIu64, m_object_offset);
+ dumped_something = true;
+ }
+ if (m_object_size > 0) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object size = %" PRIu64, m_object_size);
+ dumped_something = true;
+ }
+ if (m_object_mod_time.IsValid()) {
+ if (dumped_something)
+ strm.PutCString(", ");
+ strm.Printf("object_mod_time = 0x%" PRIx64,
+ m_object_mod_time.GetAsSecondsSinceJan1_1970());
+ }
+ }
+
+ bool Matches(const ModuleSpec &match_module_spec,
+ bool exact_arch_match) const {
+ if (match_module_spec.GetUUIDPtr() &&
+ match_module_spec.GetUUID() != GetUUID())
+ return false;
+ if (match_module_spec.GetObjectName() &&
+ match_module_spec.GetObjectName() != GetObjectName())
+ return false;
+ if (match_module_spec.GetFileSpecPtr()) {
+ const FileSpec &fspec = match_module_spec.GetFileSpec();
+ if (!FileSpec::Equal(fspec, GetFileSpec(),
+ fspec.GetDirectory().IsEmpty() == false))
+ return false;
}
-
- FileSpec *
- GetFileSpecPtr ()
- {
- return (m_file ? &m_file : nullptr);
- }
-
- const FileSpec *
- GetFileSpecPtr () const
- {
- return (m_file ? &m_file : nullptr);
- }
-
- FileSpec &
- GetFileSpec ()
- {
- return m_file;
- }
-
- const FileSpec &
- GetFileSpec () const
- {
- return m_file;
- }
-
- FileSpec *
- GetPlatformFileSpecPtr ()
- {
- return (m_platform_file ? &m_platform_file : nullptr);
- }
-
- const FileSpec *
- GetPlatformFileSpecPtr () const
- {
- return (m_platform_file ? &m_platform_file : nullptr);
- }
-
- FileSpec &
- GetPlatformFileSpec ()
- {
- return m_platform_file;
- }
-
- const FileSpec &
- GetPlatformFileSpec () const
- {
- return m_platform_file;
- }
-
- FileSpec *
- GetSymbolFileSpecPtr ()
- {
- return (m_symbol_file ? &m_symbol_file : nullptr);
- }
-
- const FileSpec *
- GetSymbolFileSpecPtr () const
- {
- return (m_symbol_file ? &m_symbol_file : nullptr);
- }
-
- FileSpec &
- GetSymbolFileSpec ()
- {
- return m_symbol_file;
- }
-
- const FileSpec &
- GetSymbolFileSpec () const
- {
- return m_symbol_file;
- }
-
- ArchSpec *
- GetArchitecturePtr ()
- {
- return (m_arch.IsValid() ? &m_arch : nullptr);
- }
-
- const ArchSpec *
- GetArchitecturePtr () const
- {
- return (m_arch.IsValid() ? &m_arch : nullptr);
- }
-
- ArchSpec &
- GetArchitecture ()
- {
- return m_arch;
- }
-
- const ArchSpec &
- GetArchitecture () const
- {
- return m_arch;
- }
-
- UUID *
- GetUUIDPtr ()
- {
- return (m_uuid.IsValid() ? &m_uuid : nullptr);
- }
-
- const UUID *
- GetUUIDPtr () const
- {
- return (m_uuid.IsValid() ? &m_uuid : nullptr);
- }
-
- UUID &
- GetUUID ()
- {
- return m_uuid;
- }
-
- const UUID &
- GetUUID () const
- {
- return m_uuid;
- }
-
- ConstString &
- GetObjectName ()
- {
- return m_object_name;
- }
-
- const ConstString &
- GetObjectName () const
- {
- return m_object_name;
- }
-
- uint64_t
- GetObjectOffset () const
- {
- return m_object_offset;
- }
-
- void
- SetObjectOffset (uint64_t object_offset)
- {
- m_object_offset = object_offset;
- }
-
- uint64_t
- GetObjectSize () const
- {
- return m_object_size;
- }
-
- void
- SetObjectSize (uint64_t object_size)
- {
- m_object_size = object_size;
- }
-
- TimeValue &
- GetObjectModificationTime ()
- {
- return m_object_mod_time;
- }
-
- const TimeValue &
- GetObjectModificationTime () const
- {
- return m_object_mod_time;
- }
-
- PathMappingList &
- GetSourceMappingList () const
- {
- return m_source_mappings;
- }
-
- void
- Clear ()
- {
- m_file.Clear();
- m_platform_file.Clear();
- m_symbol_file.Clear();
- m_arch.Clear();
- m_uuid.Clear();
- m_object_name.Clear();
- m_object_offset = 0;
- m_object_size = 0;
- m_source_mappings.Clear(false);
- m_object_mod_time.Clear();
- }
-
- explicit operator bool () const
- {
- if (m_file)
- return true;
- if (m_platform_file)
- return true;
- if (m_symbol_file)
- return true;
- if (m_arch.IsValid())
- return true;
- if (m_uuid.IsValid())
- return true;
- if (m_object_name)
- return true;
- if (m_object_size)
- return true;
- if (m_object_mod_time.IsValid())
- return true;
+ if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr()) {
+ const FileSpec &fspec = match_module_spec.GetPlatformFileSpec();
+ if (!FileSpec::Equal(fspec, GetPlatformFileSpec(),
+ fspec.GetDirectory().IsEmpty() == false))
return false;
}
-
- void
- Dump (Stream &strm) const
- {
- bool dumped_something = false;
- if (m_file)
- {
- strm.PutCString("file = '");
- strm << m_file;
- strm.PutCString("'");
- dumped_something = true;
- }
- if (m_platform_file)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.PutCString("platform_file = '");
- strm << m_platform_file;
- strm.PutCString("'");
- dumped_something = true;
- }
- if (m_symbol_file)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.PutCString("symbol_file = '");
- strm << m_symbol_file;
- strm.PutCString("'");
- dumped_something = true;
- }
- if (m_arch.IsValid())
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("arch = ");
- m_arch.DumpTriple(strm);
- dumped_something = true;
- }
- if (m_uuid.IsValid())
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.PutCString("uuid = ");
- m_uuid.Dump(&strm);
- dumped_something = true;
- }
- if (m_object_name)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object_name = %s", m_object_name.GetCString());
- dumped_something = true;
- }
- if (m_object_offset > 0)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object_offset = %" PRIu64, m_object_offset);
- dumped_something = true;
- }
- if (m_object_size > 0)
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object size = %" PRIu64, m_object_size);
- dumped_something = true;
- }
- if (m_object_mod_time.IsValid())
- {
- if (dumped_something)
- strm.PutCString(", ");
- strm.Printf("object_mod_time = 0x%" PRIx64, m_object_mod_time.GetAsSecondsSinceJan1_1970());
- }
+ // Only match the symbol file spec if there is one in this ModuleSpec
+ if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr()) {
+ const FileSpec &fspec = match_module_spec.GetSymbolFileSpec();
+ if (!FileSpec::Equal(fspec, GetSymbolFileSpec(),
+ fspec.GetDirectory().IsEmpty() == false))
+ return false;
}
-
- bool
- Matches (const ModuleSpec &match_module_spec, bool exact_arch_match) const
- {
- if (match_module_spec.GetUUIDPtr() && match_module_spec.GetUUID() != GetUUID())
- return false;
- if (match_module_spec.GetObjectName() && match_module_spec.GetObjectName() != GetObjectName())
- return false;
- if (match_module_spec.GetFileSpecPtr())
- {
- const FileSpec &fspec = match_module_spec.GetFileSpec();
- if (!FileSpec::Equal(fspec, GetFileSpec(), fspec.GetDirectory().IsEmpty() == false))
- return false;
- }
- if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr())
- {
- const FileSpec &fspec = match_module_spec.GetPlatformFileSpec();
- if (!FileSpec::Equal(fspec, GetPlatformFileSpec(), fspec.GetDirectory().IsEmpty() == false))
- return false;
-
- }
- // Only match the symbol file spec if there is one in this ModuleSpec
- if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr())
- {
- const FileSpec &fspec = match_module_spec.GetSymbolFileSpec();
- if (!FileSpec::Equal(fspec, GetSymbolFileSpec(), fspec.GetDirectory().IsEmpty() == false))
- return false;
-
- }
- if (match_module_spec.GetArchitecturePtr())
- {
- if (exact_arch_match)
- {
- if (!GetArchitecture().IsExactMatch(match_module_spec.GetArchitecture()))
- return false;
- }
- else
- {
- if (!GetArchitecture().IsCompatibleMatch(match_module_spec.GetArchitecture()))
- return false;
- }
- }
- return true;
+ if (match_module_spec.GetArchitecturePtr()) {
+ if (exact_arch_match) {
+ if (!GetArchitecture().IsExactMatch(
+ match_module_spec.GetArchitecture()))
+ return false;
+ } else {
+ if (!GetArchitecture().IsCompatibleMatch(
+ match_module_spec.GetArchitecture()))
+ return false;
+ }
}
+ return true;
+ }
protected:
- FileSpec m_file;
- FileSpec m_platform_file;
- FileSpec m_symbol_file;
- ArchSpec m_arch;
- UUID m_uuid;
- ConstString m_object_name;
- uint64_t m_object_offset;
- uint64_t m_object_size;
- TimeValue m_object_mod_time;
- mutable PathMappingList m_source_mappings;
+ FileSpec m_file;
+ FileSpec m_platform_file;
+ FileSpec m_symbol_file;
+ ArchSpec m_arch;
+ UUID m_uuid;
+ ConstString m_object_name;
+ uint64_t m_object_offset;
+ uint64_t m_object_size;
+ TimeValue m_object_mod_time;
+ mutable PathMappingList m_source_mappings;
};
-class ModuleSpecList
-{
+class ModuleSpecList {
public:
- ModuleSpecList() : m_specs(), m_mutex() {}
-
- ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex()
- {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
- m_specs = rhs.m_specs;
- }
-
- ~ModuleSpecList() = default;
-
- ModuleSpecList &
- operator=(const ModuleSpecList &rhs)
- {
- if (this != &rhs)
- {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
- m_specs = rhs.m_specs;
- }
- return *this;
- }
-
- size_t
- GetSize() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_specs.size();
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_specs.clear();
- }
-
- void
- Append(const ModuleSpec &spec)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_specs.push_back(spec);
- }
-
- void
- Append(const ModuleSpecList &rhs)
- {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
- m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
- }
-
- // The index "i" must be valid and this can't be used in
- // multi-threaded code as no mutex lock is taken.
- ModuleSpec &
- GetModuleSpecRefAtIndex (size_t i)
- {
- return m_specs[i];
- }
-
- bool
- GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (i < m_specs.size())
- {
- module_spec = m_specs[i];
- return true;
- }
- module_spec.Clear();
- return false;
- }
-
- bool
- FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- bool exact_arch_match = true;
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- {
- match_module_spec = spec;
- return true;
- }
- }
+ ModuleSpecList() : m_specs(), m_mutex() {}
- // If there was an architecture, retry with a compatible arch
- if (module_spec.GetArchitecturePtr())
- {
- exact_arch_match = false;
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- {
- match_module_spec = spec;
- return true;
- }
- }
- }
- match_module_spec.Clear();
- return false;
- }
-
- size_t
- FindMatchingModuleSpecs(const ModuleSpec &module_spec, ModuleSpecList &matching_list) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- bool exact_arch_match = true;
- const size_t initial_match_count = matching_list.GetSize();
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- matching_list.Append(spec);
- }
-
- // If there was an architecture, retry with a compatible arch if no matches were found
- if (module_spec.GetArchitecturePtr() && (initial_match_count == matching_list.GetSize()))
- {
- exact_arch_match = false;
- for (auto spec : m_specs)
- {
- if (spec.Matches(module_spec, exact_arch_match))
- matching_list.Append(spec);
- }
- }
- return matching_list.GetSize() - initial_match_count;
+ ModuleSpecList(const ModuleSpecList &rhs) : m_specs(), m_mutex() {
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ m_specs = rhs.m_specs;
+ }
+
+ ~ModuleSpecList() = default;
+
+ ModuleSpecList &operator=(const ModuleSpecList &rhs) {
+ if (this != &rhs) {
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ m_specs = rhs.m_specs;
+ }
+ return *this;
+ }
+
+ size_t GetSize() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_specs.size();
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_specs.clear();
+ }
+
+ void Append(const ModuleSpec &spec) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_specs.push_back(spec);
+ }
+
+ void Append(const ModuleSpecList &rhs) {
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end());
+ }
+
+ // The index "i" must be valid and this can't be used in
+ // multi-threaded code as no mutex lock is taken.
+ ModuleSpec &GetModuleSpecRefAtIndex(size_t i) { return m_specs[i]; }
+
+ bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (i < m_specs.size()) {
+ module_spec = m_specs[i];
+ return true;
+ }
+ module_spec.Clear();
+ return false;
+ }
+
+ bool FindMatchingModuleSpec(const ModuleSpec &module_spec,
+ ModuleSpec &match_module_spec) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ bool exact_arch_match = true;
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match)) {
+ match_module_spec = spec;
+ return true;
+ }
}
- void
- Dump(Stream &strm)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- uint32_t idx = 0;
- for (auto spec : m_specs)
- {
- strm.Printf("[%u] ", idx);
- spec.Dump(strm);
- strm.EOL();
- ++idx;
- }
+ // If there was an architecture, retry with a compatible arch
+ if (module_spec.GetArchitecturePtr()) {
+ exact_arch_match = false;
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match)) {
+ match_module_spec = spec;
+ return true;
+ }
+ }
+ }
+ match_module_spec.Clear();
+ return false;
+ }
+
+ size_t FindMatchingModuleSpecs(const ModuleSpec &module_spec,
+ ModuleSpecList &matching_list) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ bool exact_arch_match = true;
+ const size_t initial_match_count = matching_list.GetSize();
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match))
+ matching_list.Append(spec);
+ }
+
+ // If there was an architecture, retry with a compatible arch if no matches
+ // were found
+ if (module_spec.GetArchitecturePtr() &&
+ (initial_match_count == matching_list.GetSize())) {
+ exact_arch_match = false;
+ for (auto spec : m_specs) {
+ if (spec.Matches(module_spec, exact_arch_match))
+ matching_list.Append(spec);
+ }
+ }
+ return matching_list.GetSize() - initial_match_count;
+ }
+
+ void Dump(Stream &strm) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ uint32_t idx = 0;
+ for (auto spec : m_specs) {
+ strm.Printf("[%u] ", idx);
+ spec.Dump(strm);
+ strm.EOL();
+ ++idx;
}
+ }
protected:
- typedef std::vector<ModuleSpec> collection; ///< The module collection type.
- collection m_specs; ///< The collection of modules.
- mutable std::recursive_mutex m_mutex;
+ typedef std::vector<ModuleSpec> collection; ///< The module collection type.
+ collection m_specs; ///< The collection of modules.
+ mutable std::recursive_mutex m_mutex;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Opcode.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Opcode.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Opcode.h (original)
+++ lldb/trunk/include/lldb/Core/Opcode.h Tue Sep 6 15:57:50 2016
@@ -21,266 +21,253 @@
#include "lldb/Host/Endian.h"
#include "lldb/lldb-public.h"
-namespace lldb
-{
- class SBInstruction;
+namespace lldb {
+class SBInstruction;
} // namespace lldb
namespace lldb_private {
- class Opcode
- {
- public:
- enum Type
- {
- eTypeInvalid,
- eType8,
- eType16,
- eType16_2, // a 32-bit Thumb instruction, made up of two words
- eType32,
- eType64,
- eTypeBytes
- };
-
- Opcode () : m_byte_order (lldb::eByteOrderInvalid), m_type (eTypeInvalid)
- {
- }
-
- Opcode (uint8_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType8)
- {
- m_data.inst8 = inst;
- }
-
- Opcode (uint16_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType16)
- {
- m_data.inst16 = inst;
- }
-
- Opcode (uint32_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType32)
- {
- m_data.inst32 = inst;
- }
-
- Opcode (uint64_t inst, lldb::ByteOrder order) : m_byte_order (order), m_type (eType64)
- {
- m_data.inst64 = inst;
- }
-
- Opcode (uint8_t *bytes, size_t length) : m_byte_order (lldb::eByteOrderInvalid)
- {
- SetOpcodeBytes (bytes, length);
- }
-
- void
- Clear()
- {
- m_byte_order = lldb::eByteOrderInvalid;
- m_type = Opcode::eTypeInvalid;
- }
-
- Opcode::Type
- GetType () const
- {
- return m_type;
- }
-
- uint8_t
- GetOpcode8 (uint8_t invalid_opcode = UINT8_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: break;
- case Opcode::eType16_2: break;
- case Opcode::eType32: break;
- case Opcode::eType64: break;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- uint16_t
- GetOpcode16 (uint16_t invalid_opcode = UINT16_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
- case Opcode::eType16_2: break;
- case Opcode::eType32: break;
- case Opcode::eType64: break;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- uint32_t
- GetOpcode32 (uint32_t invalid_opcode = UINT32_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
- case Opcode::eType64: break;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- uint64_t
- GetOpcode64 (uint64_t invalid_opcode = UINT64_MAX) const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return m_data.inst8;
- case Opcode::eType16: return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
- case Opcode::eType64: return GetEndianSwap() ? llvm::ByteSwap_64(m_data.inst64) : m_data.inst64;
- case Opcode::eTypeBytes: break;
- }
- return invalid_opcode;
- }
-
- void
- SetOpcode8 (uint8_t inst, lldb::ByteOrder order)
- {
- m_type = eType8;
- m_data.inst8 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode16 (uint16_t inst, lldb::ByteOrder order)
- {
- m_type = eType16;
- m_data.inst16 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode16_2 (uint32_t inst, lldb::ByteOrder order)
- {
- m_type = eType16_2;
- m_data.inst32 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode32 (uint32_t inst, lldb::ByteOrder order)
- {
- m_type = eType32;
- m_data.inst32 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcode64 (uint64_t inst, lldb::ByteOrder order)
- {
- m_type = eType64;
- m_data.inst64 = inst;
- m_byte_order = order;
- }
-
- void
- SetOpcodeBytes (const void *bytes, size_t length)
- {
- if (bytes != nullptr && length > 0)
- {
- m_type = eTypeBytes;
- m_data.inst.length = length;
- assert (length < sizeof (m_data.inst.bytes));
- memcpy (m_data.inst.bytes, bytes, length);
- m_byte_order = lldb::eByteOrderInvalid;
- }
- else
- {
- m_type = eTypeInvalid;
- m_data.inst.length = 0;
- }
- }
-
- int
- Dump (Stream *s, uint32_t min_byte_width);
-
- const void *
- GetOpcodeBytes () const
- {
- return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
- }
-
- uint32_t
- GetByteSize () const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return sizeof(m_data.inst8);
- case Opcode::eType16: return sizeof(m_data.inst16);
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return sizeof(m_data.inst32);
- case Opcode::eType64: return sizeof(m_data.inst64);
- case Opcode::eTypeBytes: return m_data.inst.length;
- }
- return 0;
- }
-
- // Get the opcode exactly as it would be laid out in memory.
- uint32_t
- GetData (DataExtractor &data) const;
-
- protected:
-
- friend class lldb::SBInstruction;
-
- const void *
- GetOpcodeDataBytes () const
- {
- switch (m_type)
- {
- case Opcode::eTypeInvalid: break;
- case Opcode::eType8: return &m_data.inst8;
- case Opcode::eType16: return &m_data.inst16;
- case Opcode::eType16_2: // passthrough
- case Opcode::eType32: return &m_data.inst32;
- case Opcode::eType64: return &m_data.inst64;
- case Opcode::eTypeBytes: return m_data.inst.bytes;
- }
- return nullptr;
- }
-
- lldb::ByteOrder
- GetDataByteOrder () const;
-
- bool
- GetEndianSwap() const
- {
- return (m_byte_order == lldb::eByteOrderBig && endian::InlHostByteOrder() == lldb::eByteOrderLittle) ||
- (m_byte_order == lldb::eByteOrderLittle && endian::InlHostByteOrder() == lldb::eByteOrderBig);
- }
-
- lldb::ByteOrder m_byte_order;
-
- Opcode::Type m_type;
- union
- {
- uint8_t inst8;
- uint16_t inst16;
- uint32_t inst32;
- uint64_t inst64;
- struct
- {
- uint8_t bytes[16]; // This must be big enough to handle any opcode for any supported target.
- uint8_t length;
- } inst;
- } m_data;
- };
+class Opcode {
+public:
+ enum Type {
+ eTypeInvalid,
+ eType8,
+ eType16,
+ eType16_2, // a 32-bit Thumb instruction, made up of two words
+ eType32,
+ eType64,
+ eTypeBytes
+ };
+
+ Opcode() : m_byte_order(lldb::eByteOrderInvalid), m_type(eTypeInvalid) {}
+
+ Opcode(uint8_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType8) {
+ m_data.inst8 = inst;
+ }
+
+ Opcode(uint16_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType16) {
+ m_data.inst16 = inst;
+ }
+
+ Opcode(uint32_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType32) {
+ m_data.inst32 = inst;
+ }
+
+ Opcode(uint64_t inst, lldb::ByteOrder order)
+ : m_byte_order(order), m_type(eType64) {
+ m_data.inst64 = inst;
+ }
+
+ Opcode(uint8_t *bytes, size_t length)
+ : m_byte_order(lldb::eByteOrderInvalid) {
+ SetOpcodeBytes(bytes, length);
+ }
+
+ void Clear() {
+ m_byte_order = lldb::eByteOrderInvalid;
+ m_type = Opcode::eTypeInvalid;
+ }
+
+ Opcode::Type GetType() const { return m_type; }
+
+ uint8_t GetOpcode8(uint8_t invalid_opcode = UINT8_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ break;
+ case Opcode::eType16_2:
+ break;
+ case Opcode::eType32:
+ break;
+ case Opcode::eType64:
+ break;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ uint16_t GetOpcode16(uint16_t invalid_opcode = UINT16_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ case Opcode::eType16_2:
+ break;
+ case Opcode::eType32:
+ break;
+ case Opcode::eType64:
+ break;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ uint32_t GetOpcode32(uint32_t invalid_opcode = UINT32_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
+ case Opcode::eType64:
+ break;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ uint64_t GetOpcode64(uint64_t invalid_opcode = UINT64_MAX) const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return m_data.inst8;
+ case Opcode::eType16:
+ return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : m_data.inst16;
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : m_data.inst32;
+ case Opcode::eType64:
+ return GetEndianSwap() ? llvm::ByteSwap_64(m_data.inst64) : m_data.inst64;
+ case Opcode::eTypeBytes:
+ break;
+ }
+ return invalid_opcode;
+ }
+
+ void SetOpcode8(uint8_t inst, lldb::ByteOrder order) {
+ m_type = eType8;
+ m_data.inst8 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode16(uint16_t inst, lldb::ByteOrder order) {
+ m_type = eType16;
+ m_data.inst16 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode16_2(uint32_t inst, lldb::ByteOrder order) {
+ m_type = eType16_2;
+ m_data.inst32 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode32(uint32_t inst, lldb::ByteOrder order) {
+ m_type = eType32;
+ m_data.inst32 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcode64(uint64_t inst, lldb::ByteOrder order) {
+ m_type = eType64;
+ m_data.inst64 = inst;
+ m_byte_order = order;
+ }
+
+ void SetOpcodeBytes(const void *bytes, size_t length) {
+ if (bytes != nullptr && length > 0) {
+ m_type = eTypeBytes;
+ m_data.inst.length = length;
+ assert(length < sizeof(m_data.inst.bytes));
+ memcpy(m_data.inst.bytes, bytes, length);
+ m_byte_order = lldb::eByteOrderInvalid;
+ } else {
+ m_type = eTypeInvalid;
+ m_data.inst.length = 0;
+ }
+ }
+
+ int Dump(Stream *s, uint32_t min_byte_width);
+
+ const void *GetOpcodeBytes() const {
+ return ((m_type == Opcode::eTypeBytes) ? m_data.inst.bytes : nullptr);
+ }
+
+ uint32_t GetByteSize() const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return sizeof(m_data.inst8);
+ case Opcode::eType16:
+ return sizeof(m_data.inst16);
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return sizeof(m_data.inst32);
+ case Opcode::eType64:
+ return sizeof(m_data.inst64);
+ case Opcode::eTypeBytes:
+ return m_data.inst.length;
+ }
+ return 0;
+ }
+
+ // Get the opcode exactly as it would be laid out in memory.
+ uint32_t GetData(DataExtractor &data) const;
+
+protected:
+ friend class lldb::SBInstruction;
+
+ const void *GetOpcodeDataBytes() const {
+ switch (m_type) {
+ case Opcode::eTypeInvalid:
+ break;
+ case Opcode::eType8:
+ return &m_data.inst8;
+ case Opcode::eType16:
+ return &m_data.inst16;
+ case Opcode::eType16_2: // passthrough
+ case Opcode::eType32:
+ return &m_data.inst32;
+ case Opcode::eType64:
+ return &m_data.inst64;
+ case Opcode::eTypeBytes:
+ return m_data.inst.bytes;
+ }
+ return nullptr;
+ }
+
+ lldb::ByteOrder GetDataByteOrder() const;
+
+ bool GetEndianSwap() const {
+ return (m_byte_order == lldb::eByteOrderBig &&
+ endian::InlHostByteOrder() == lldb::eByteOrderLittle) ||
+ (m_byte_order == lldb::eByteOrderLittle &&
+ endian::InlHostByteOrder() == lldb::eByteOrderBig);
+ }
+
+ lldb::ByteOrder m_byte_order;
+
+ Opcode::Type m_type;
+ union {
+ uint8_t inst8;
+ uint16_t inst16;
+ uint32_t inst32;
+ uint64_t inst64;
+ struct {
+ uint8_t bytes[16]; // This must be big enough to handle any opcode for any
+ // supported target.
+ uint8_t length;
+ } inst;
+ } m_data;
+};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/PluginInterface.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginInterface.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginInterface.h (original)
+++ lldb/trunk/include/lldb/Core/PluginInterface.h Tue Sep 6 15:57:50 2016
@@ -18,20 +18,15 @@
namespace lldb_private {
-class PluginInterface
-{
+class PluginInterface {
public:
- virtual
- ~PluginInterface () {}
+ virtual ~PluginInterface() {}
- virtual ConstString
- GetPluginName() = 0;
-
- virtual uint32_t
- GetPluginVersion() = 0;
+ virtual ConstString GetPluginName() = 0;
+ virtual uint32_t GetPluginVersion() = 0;
};
} // namespace lldb_private
-#endif // liblldb_PluginInterface_h_
+#endif // liblldb_PluginInterface_h_
Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Tue Sep 6 15:57:50 2016
@@ -14,592 +14,517 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class PluginManager
-{
+class PluginManager {
public:
- static void
- Initialize ();
-
- static void
- Terminate ();
-
- //------------------------------------------------------------------
- // ABI
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- ABICreateInstance create_callback);
-
- static bool
- UnregisterPlugin (ABICreateInstance create_callback);
-
- static ABICreateInstance
- GetABICreateCallbackAtIndex (uint32_t idx);
-
- static ABICreateInstance
- GetABICreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // Disassembler
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- DisassemblerCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (DisassemblerCreateInstance create_callback);
-
- static DisassemblerCreateInstance
- GetDisassemblerCreateCallbackAtIndex (uint32_t idx);
-
- static DisassemblerCreateInstance
- GetDisassemblerCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // DynamicLoader
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- DynamicLoaderCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (DynamicLoaderCreateInstance create_callback);
-
- static DynamicLoaderCreateInstance
- GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx);
-
- static DynamicLoaderCreateInstance
- GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // JITLoader
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- JITLoaderCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (JITLoaderCreateInstance create_callback);
-
- static JITLoaderCreateInstance
- GetJITLoaderCreateCallbackAtIndex (uint32_t idx);
-
- static JITLoaderCreateInstance
- GetJITLoaderCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // EmulateInstruction
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- EmulateInstructionCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (EmulateInstructionCreateInstance create_callback);
-
- static EmulateInstructionCreateInstance
- GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx);
-
- static EmulateInstructionCreateInstance
- GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // OperatingSystem
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
- OperatingSystemCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback);
-
- static bool
- UnregisterPlugin (OperatingSystemCreateInstance create_callback);
-
- static OperatingSystemCreateInstance
- GetOperatingSystemCreateCallbackAtIndex (uint32_t idx);
-
- static OperatingSystemCreateInstance
- GetOperatingSystemCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // Language
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- LanguageCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (LanguageCreateInstance create_callback);
-
- static LanguageCreateInstance
- GetLanguageCreateCallbackAtIndex (uint32_t idx);
-
- static LanguageCreateInstance
- GetLanguageCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // LanguageRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- LanguageRuntimeCreateInstance create_callback,
- LanguageRuntimeGetCommandObject command_callback = nullptr);
-
- static bool
- UnregisterPlugin (LanguageRuntimeCreateInstance create_callback);
-
- static LanguageRuntimeCreateInstance
- GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx);
-
- static LanguageRuntimeGetCommandObject
- GetLanguageRuntimeGetCommandObjectAtIndex (uint32_t idx);
-
- static LanguageRuntimeCreateInstance
- GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // SystemRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- SystemRuntimeCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (SystemRuntimeCreateInstance create_callback);
-
- static SystemRuntimeCreateInstance
- GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx);
-
- static SystemRuntimeCreateInstance
- GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // ObjectFile
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- ObjectFileCreateInstance create_callback,
- ObjectFileCreateMemoryInstance create_memory_callback,
- ObjectFileGetModuleSpecifications get_module_specifications,
- ObjectFileSaveCore save_core = nullptr);
-
- static bool
- UnregisterPlugin (ObjectFileCreateInstance create_callback);
-
- static ObjectFileCreateInstance
- GetObjectFileCreateCallbackAtIndex (uint32_t idx);
-
- static ObjectFileCreateMemoryInstance
- GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx);
-
- static ObjectFileGetModuleSpecifications
- GetObjectFileGetModuleSpecificationsCallbackAtIndex (uint32_t idx);
-
- static ObjectFileCreateInstance
- GetObjectFileCreateCallbackForPluginName (const ConstString &name);
-
- static ObjectFileCreateMemoryInstance
- GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name);
-
- static Error
- SaveCore (const lldb::ProcessSP &process_sp, const FileSpec &outfile);
-
- //------------------------------------------------------------------
- // ObjectContainer
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- ObjectContainerCreateInstance create_callback,
- ObjectFileGetModuleSpecifications get_module_specifications);
-
- static bool
- UnregisterPlugin (ObjectContainerCreateInstance create_callback);
-
- static ObjectContainerCreateInstance
- GetObjectContainerCreateCallbackAtIndex (uint32_t idx);
-
- static ObjectContainerCreateInstance
- GetObjectContainerCreateCallbackForPluginName (const ConstString &name);
-
- static ObjectFileGetModuleSpecifications
- GetObjectContainerGetModuleSpecificationsCallbackAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- // LogChannel
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- LogChannelCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (LogChannelCreateInstance create_callback);
-
- static LogChannelCreateInstance
- GetLogChannelCreateCallbackAtIndex (uint32_t idx);
-
- static LogChannelCreateInstance
- GetLogChannelCreateCallbackForPluginName (const ConstString &name);
-
- static const char *
- GetLogChannelCreateNameAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- // Platform
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- PlatformCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (PlatformCreateInstance create_callback);
-
- static PlatformCreateInstance
- GetPlatformCreateCallbackAtIndex (uint32_t idx);
-
- static PlatformCreateInstance
- GetPlatformCreateCallbackForPluginName (const ConstString &name);
-
- static const char *
- GetPlatformPluginNameAtIndex (uint32_t idx);
-
- static const char *
- GetPlatformPluginDescriptionAtIndex (uint32_t idx);
-
- static size_t
- AutoCompletePlatformName (const char *partial_name,
- StringList &matches);
- //------------------------------------------------------------------
- // Process
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- ProcessCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (ProcessCreateInstance create_callback);
-
- static ProcessCreateInstance
- GetProcessCreateCallbackAtIndex (uint32_t idx);
-
- static ProcessCreateInstance
- GetProcessCreateCallbackForPluginName (const ConstString &name);
-
- static const char *
- GetProcessPluginNameAtIndex (uint32_t idx);
-
- static const char *
- GetProcessPluginDescriptionAtIndex (uint32_t idx);
-
- //------------------------------------------------------------------
- // ScriptInterpreter
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name, const char *description, lldb::ScriptLanguage script_lang,
- ScriptInterpreterCreateInstance create_callback);
-
- static bool
- UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
-
- static ScriptInterpreterCreateInstance
- GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
-
- static lldb::ScriptInterpreterSP
- GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
- CommandInterpreter &interpreter);
-
- //------------------------------------------------------------------
- // StructuredDataPlugin
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Register a StructuredDataPlugin class along with optional
- /// callbacks for debugger initialization and Process launch info
- /// filtering and manipulation.
- ///
- /// @param[in] name
- /// The name of the plugin.
- ///
- /// @param[in] description
- /// A description string for the plugin.
- ///
- /// @param[in] create_callback
- /// The callback that will be invoked to create an instance of
- /// the callback. This may not be nullptr.
- ///
- /// @param[in] debugger_init_callback
- /// An optional callback that will be made when a Debugger
- /// instance is initialized.
- ///
- /// @param[in] filter_callback
- /// An optional callback that will be invoked before LLDB
- /// launches a process for debugging. The callback must
- /// do the following:
- /// 1. Only do something if the plugin's behavior is enabled.
- /// 2. Only make changes for processes that are relevant to the
- /// plugin. The callback gets a pointer to the Target, which
- /// can be inspected as needed. The ProcessLaunchInfo is
- /// provided in read-write mode, and may be modified by the
- /// plugin if, for instance, additional environment variables
- /// are needed to support the feature when enabled.
- ///
- /// @return
- /// Returns true upon success; otherwise, false.
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name,
- const char *description,
- StructuredDataPluginCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr,
- StructuredDataFilterLaunchInfo filter_callback
- = nullptr);
-
- static bool
- UnregisterPlugin(StructuredDataPluginCreateInstance create_callback);
-
- static StructuredDataPluginCreateInstance
- GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
-
- static StructuredDataPluginCreateInstance
- GetStructuredDataPluginCreateCallbackForPluginName(const ConstString &name);
-
- static StructuredDataFilterLaunchInfo
- GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
- bool &iteration_complete);
-
- //------------------------------------------------------------------
- // SymbolFile
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- SymbolFileCreateInstance create_callback,
- DebuggerInitializeCallback debugger_init_callback = nullptr);
-
- static bool
- UnregisterPlugin (SymbolFileCreateInstance create_callback);
-
- static SymbolFileCreateInstance
- GetSymbolFileCreateCallbackAtIndex (uint32_t idx);
-
- static SymbolFileCreateInstance
- GetSymbolFileCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // SymbolVendor
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- SymbolVendorCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (SymbolVendorCreateInstance create_callback);
-
- static SymbolVendorCreateInstance
- GetSymbolVendorCreateCallbackAtIndex (uint32_t idx);
-
- static SymbolVendorCreateInstance
- GetSymbolVendorCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // UnwindAssembly
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- UnwindAssemblyCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (UnwindAssemblyCreateInstance create_callback);
-
- static UnwindAssemblyCreateInstance
- GetUnwindAssemblyCreateCallbackAtIndex (uint32_t idx);
-
- static UnwindAssemblyCreateInstance
- GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // MemoryHistory
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- MemoryHistoryCreateInstance create_callback);
-
- static bool
- UnregisterPlugin (MemoryHistoryCreateInstance create_callback);
-
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackAtIndex (uint32_t idx);
-
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // InstrumentationRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- InstrumentationRuntimeCreateInstance create_callback,
- InstrumentationRuntimeGetType get_type_callback);
-
- static bool
- UnregisterPlugin (InstrumentationRuntimeCreateInstance create_callback);
-
- static InstrumentationRuntimeGetType
- GetInstrumentationRuntimeGetTypeCallbackAtIndex (uint32_t idx);
-
- static InstrumentationRuntimeCreateInstance
- GetInstrumentationRuntimeCreateCallbackAtIndex (uint32_t idx);
-
- static InstrumentationRuntimeCreateInstance
- GetInstrumentationRuntimeCreateCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // TypeSystem
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- TypeSystemCreateInstance create_callback,
- TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
-
- static bool
- UnregisterPlugin (TypeSystemCreateInstance create_callback);
-
- static TypeSystemCreateInstance
- GetTypeSystemCreateCallbackAtIndex (uint32_t idx);
-
- static TypeSystemCreateInstance
- GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
-
- static TypeSystemEnumerateSupportedLanguages
- GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
-
- static TypeSystemEnumerateSupportedLanguages
- GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // REPL
- //------------------------------------------------------------------
- static bool
- RegisterPlugin (const ConstString &name,
- const char *description,
- REPLCreateInstance create_callback,
- REPLEnumerateSupportedLanguages enumerate_languages_callback);
-
- static bool
- UnregisterPlugin (REPLCreateInstance create_callback);
-
- static REPLCreateInstance
- GetREPLCreateCallbackAtIndex (uint32_t idx);
-
- static REPLCreateInstance
- GetREPLCreateCallbackForPluginName (const ConstString &name);
-
- static REPLEnumerateSupportedLanguages
- GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
-
- static REPLEnumerateSupportedLanguages
- GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
-
- //------------------------------------------------------------------
- // Some plug-ins might register a DebuggerInitializeCallback
- // callback when registering the plug-in. After a new Debugger
- // instance is created, this DebuggerInitialize function will get
- // called. This allows plug-ins to install Properties and do any
- // other initialization that requires a debugger instance.
- //------------------------------------------------------------------
- static void
- DebuggerInitialize (Debugger &debugger);
-
- static lldb::OptionValuePropertiesSP
- GetSettingForDynamicLoaderPlugin (Debugger &debugger,
- const ConstString &setting_name);
-
- static bool
- CreateSettingForDynamicLoaderPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
-
- static lldb::OptionValuePropertiesSP
- GetSettingForPlatformPlugin (Debugger &debugger,
- const ConstString &setting_name);
-
- static bool
- CreateSettingForPlatformPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ static void Initialize();
- static lldb::OptionValuePropertiesSP
- GetSettingForProcessPlugin (Debugger &debugger,
- const ConstString &setting_name);
+ static void Terminate();
- static bool
- CreateSettingForProcessPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ //------------------------------------------------------------------
+ // ABI
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ ABICreateInstance create_callback);
- static lldb::OptionValuePropertiesSP
- GetSettingForSymbolFilePlugin (Debugger &debugger,
- const ConstString &setting_name);
+ static bool UnregisterPlugin(ABICreateInstance create_callback);
+
+ static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
+
+ static ABICreateInstance
+ GetABICreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Disassembler
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ DisassemblerCreateInstance create_callback);
+
+ static bool UnregisterPlugin(DisassemblerCreateInstance create_callback);
+
+ static DisassemblerCreateInstance
+ GetDisassemblerCreateCallbackAtIndex(uint32_t idx);
+
+ static DisassemblerCreateInstance
+ GetDisassemblerCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // DynamicLoader
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ DynamicLoaderCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(DynamicLoaderCreateInstance create_callback);
+
+ static DynamicLoaderCreateInstance
+ GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
+
+ static DynamicLoaderCreateInstance
+ GetDynamicLoaderCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // JITLoader
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ JITLoaderCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(JITLoaderCreateInstance create_callback);
+
+ static JITLoaderCreateInstance
+ GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
+
+ static JITLoaderCreateInstance
+ GetJITLoaderCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // EmulateInstruction
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ EmulateInstructionCreateInstance create_callback);
+
+ static bool
+ UnregisterPlugin(EmulateInstructionCreateInstance create_callback);
+
+ static EmulateInstructionCreateInstance
+ GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
+
+ static EmulateInstructionCreateInstance
+ GetEmulateInstructionCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // OperatingSystem
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ OperatingSystemCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback);
+
+ static bool UnregisterPlugin(OperatingSystemCreateInstance create_callback);
+
+ static OperatingSystemCreateInstance
+ GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
+
+ static OperatingSystemCreateInstance
+ GetOperatingSystemCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Language
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ LanguageCreateInstance create_callback);
+
+ static bool UnregisterPlugin(LanguageCreateInstance create_callback);
+
+ static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
+
+ static LanguageCreateInstance
+ GetLanguageCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // LanguageRuntime
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ LanguageRuntimeCreateInstance create_callback,
+ LanguageRuntimeGetCommandObject command_callback = nullptr);
+
+ static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback);
+
+ static LanguageRuntimeCreateInstance
+ GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx);
+
+ static LanguageRuntimeGetCommandObject
+ GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx);
+
+ static LanguageRuntimeCreateInstance
+ GetLanguageRuntimeCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // SystemRuntime
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ SystemRuntimeCreateInstance create_callback);
+
+ static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
+
+ static SystemRuntimeCreateInstance
+ GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
+
+ static SystemRuntimeCreateInstance
+ GetSystemRuntimeCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // ObjectFile
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ ObjectFileCreateInstance create_callback,
+ ObjectFileCreateMemoryInstance create_memory_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications,
+ ObjectFileSaveCore save_core = nullptr);
+
+ static bool UnregisterPlugin(ObjectFileCreateInstance create_callback);
+
+ static ObjectFileCreateInstance
+ GetObjectFileCreateCallbackAtIndex(uint32_t idx);
+
+ static ObjectFileCreateMemoryInstance
+ GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx);
+
+ static ObjectFileGetModuleSpecifications
+ GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
+
+ static ObjectFileCreateInstance
+ GetObjectFileCreateCallbackForPluginName(const ConstString &name);
+
+ static ObjectFileCreateMemoryInstance
+ GetObjectFileCreateMemoryCallbackForPluginName(const ConstString &name);
+
+ static Error SaveCore(const lldb::ProcessSP &process_sp,
+ const FileSpec &outfile);
+
+ //------------------------------------------------------------------
+ // ObjectContainer
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ ObjectContainerCreateInstance create_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications);
+
+ static bool UnregisterPlugin(ObjectContainerCreateInstance create_callback);
+
+ static ObjectContainerCreateInstance
+ GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
+
+ static ObjectContainerCreateInstance
+ GetObjectContainerCreateCallbackForPluginName(const ConstString &name);
+
+ static ObjectFileGetModuleSpecifications
+ GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ // LogChannel
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ LogChannelCreateInstance create_callback);
+
+ static bool UnregisterPlugin(LogChannelCreateInstance create_callback);
+
+ static LogChannelCreateInstance
+ GetLogChannelCreateCallbackAtIndex(uint32_t idx);
+
+ static LogChannelCreateInstance
+ GetLogChannelCreateCallbackForPluginName(const ConstString &name);
+
+ static const char *GetLogChannelCreateNameAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ // Platform
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ PlatformCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
- static bool
- CreateSettingForSymbolFilePlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ static bool UnregisterPlugin(PlatformCreateInstance create_callback);
- static lldb::OptionValuePropertiesSP
- GetSettingForJITLoaderPlugin (Debugger &debugger,
+ static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
+
+ static PlatformCreateInstance
+ GetPlatformCreateCallbackForPluginName(const ConstString &name);
+
+ static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
+
+ static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx);
+
+ static size_t AutoCompletePlatformName(const char *partial_name,
+ StringList &matches);
+ //------------------------------------------------------------------
+ // Process
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ ProcessCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(ProcessCreateInstance create_callback);
+
+ static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx);
+
+ static ProcessCreateInstance
+ GetProcessCreateCallbackForPluginName(const ConstString &name);
+
+ static const char *GetProcessPluginNameAtIndex(uint32_t idx);
+
+ static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx);
+
+ //------------------------------------------------------------------
+ // ScriptInterpreter
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ lldb::ScriptLanguage script_lang,
+ ScriptInterpreterCreateInstance create_callback);
+
+ static bool UnregisterPlugin(ScriptInterpreterCreateInstance create_callback);
+
+ static ScriptInterpreterCreateInstance
+ GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx);
+
+ static lldb::ScriptInterpreterSP
+ GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
+ CommandInterpreter &interpreter);
+
+ //------------------------------------------------------------------
+ // StructuredDataPlugin
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Register a StructuredDataPlugin class along with optional
+ /// callbacks for debugger initialization and Process launch info
+ /// filtering and manipulation.
+ ///
+ /// @param[in] name
+ /// The name of the plugin.
+ ///
+ /// @param[in] description
+ /// A description string for the plugin.
+ ///
+ /// @param[in] create_callback
+ /// The callback that will be invoked to create an instance of
+ /// the callback. This may not be nullptr.
+ ///
+ /// @param[in] debugger_init_callback
+ /// An optional callback that will be made when a Debugger
+ /// instance is initialized.
+ ///
+ /// @param[in] filter_callback
+ /// An optional callback that will be invoked before LLDB
+ /// launches a process for debugging. The callback must
+ /// do the following:
+ /// 1. Only do something if the plugin's behavior is enabled.
+ /// 2. Only make changes for processes that are relevant to the
+ /// plugin. The callback gets a pointer to the Target, which
+ /// can be inspected as needed. The ProcessLaunchInfo is
+ /// provided in read-write mode, and may be modified by the
+ /// plugin if, for instance, additional environment variables
+ /// are needed to support the feature when enabled.
+ ///
+ /// @return
+ /// Returns true upon success; otherwise, false.
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ StructuredDataPluginCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr,
+ StructuredDataFilterLaunchInfo filter_callback = nullptr);
+
+ static bool
+ UnregisterPlugin(StructuredDataPluginCreateInstance create_callback);
+
+ static StructuredDataPluginCreateInstance
+ GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
+
+ static StructuredDataPluginCreateInstance
+ GetStructuredDataPluginCreateCallbackForPluginName(const ConstString &name);
+
+ static StructuredDataFilterLaunchInfo
+ GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
+ bool &iteration_complete);
+
+ //------------------------------------------------------------------
+ // SymbolFile
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ SymbolFileCreateInstance create_callback,
+ DebuggerInitializeCallback debugger_init_callback = nullptr);
+
+ static bool UnregisterPlugin(SymbolFileCreateInstance create_callback);
+
+ static SymbolFileCreateInstance
+ GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
+
+ static SymbolFileCreateInstance
+ GetSymbolFileCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // SymbolVendor
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ SymbolVendorCreateInstance create_callback);
+
+ static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
+
+ static SymbolVendorCreateInstance
+ GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
+
+ static SymbolVendorCreateInstance
+ GetSymbolVendorCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // UnwindAssembly
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ UnwindAssemblyCreateInstance create_callback);
+
+ static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback);
+
+ static UnwindAssemblyCreateInstance
+ GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
+
+ static UnwindAssemblyCreateInstance
+ GetUnwindAssemblyCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // MemoryHistory
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(const ConstString &name, const char *description,
+ MemoryHistoryCreateInstance create_callback);
+
+ static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
+
+ static MemoryHistoryCreateInstance
+ GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
+
+ static MemoryHistoryCreateInstance
+ GetMemoryHistoryCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // InstrumentationRuntime
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ InstrumentationRuntimeCreateInstance create_callback,
+ InstrumentationRuntimeGetType get_type_callback);
+
+ static bool
+ UnregisterPlugin(InstrumentationRuntimeCreateInstance create_callback);
+
+ static InstrumentationRuntimeGetType
+ GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx);
+
+ static InstrumentationRuntimeCreateInstance
+ GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
+
+ static InstrumentationRuntimeCreateInstance
+ GetInstrumentationRuntimeCreateCallbackForPluginName(const ConstString &name);
+
+ //------------------------------------------------------------------
+ // TypeSystem
+ //------------------------------------------------------------------
+ static bool RegisterPlugin(
+ const ConstString &name, const char *description,
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
+
+ static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
+
+ static TypeSystemCreateInstance
+ GetTypeSystemCreateCallbackAtIndex(uint32_t idx);
+
+ static TypeSystemCreateInstance
+ GetTypeSystemCreateCallbackForPluginName(const ConstString &name);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ const ConstString &name);
+
+ //------------------------------------------------------------------
+ // REPL
+ //------------------------------------------------------------------
+ static bool
+ RegisterPlugin(const ConstString &name, const char *description,
+ REPLCreateInstance create_callback,
+ REPLEnumerateSupportedLanguages enumerate_languages_callback);
+
+ static bool UnregisterPlugin(REPLCreateInstance create_callback);
+
+ static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx);
+
+ static REPLCreateInstance
+ GetREPLCreateCallbackForPluginName(const ConstString &name);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ const ConstString &name);
+
+ //------------------------------------------------------------------
+ // Some plug-ins might register a DebuggerInitializeCallback
+ // callback when registering the plug-in. After a new Debugger
+ // instance is created, this DebuggerInitialize function will get
+ // called. This allows plug-ins to install Properties and do any
+ // other initialization that requires a debugger instance.
+ //------------------------------------------------------------------
+ static void DebuggerInitialize(Debugger &debugger);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForDynamicLoaderPlugin(Debugger &debugger,
const ConstString &setting_name);
- static bool
- CreateSettingForJITLoaderPlugin (Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
-
- static lldb::OptionValuePropertiesSP GetSettingForOperatingSystemPlugin(Debugger &debugger,
- const ConstString &setting_name);
-
- static bool CreateSettingForOperatingSystemPlugin(Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
-
- static lldb::OptionValuePropertiesSP
- GetSettingForStructuredDataPlugin(Debugger &debugger,
- const ConstString &setting_name);
-
- static bool
- CreateSettingForStructuredDataPlugin(Debugger &debugger,
- const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description,
- bool is_global_property);
+ static bool CreateSettingForDynamicLoaderPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForPlatformPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForPlatformPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForProcessPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForProcessPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForSymbolFilePlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForSymbolFilePlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForJITLoaderPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForJITLoaderPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForOperatingSystemPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForOperatingSystemPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
+
+ static lldb::OptionValuePropertiesSP
+ GetSettingForStructuredDataPlugin(Debugger &debugger,
+ const ConstString &setting_name);
+
+ static bool CreateSettingForStructuredDataPlugin(
+ Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
+ const ConstString &description, bool is_global_property);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/RangeMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RangeMap.h (original)
+++ lldb/trunk/include/lldb/Core/RangeMap.h Tue Sep 6 15:57:50 2016
@@ -25,1545 +25,1138 @@
//#define ASSERT_RANGEMAP_ARE_SORTED
namespace lldb_private {
-
- //----------------------------------------------------------------------
- // Templatized classes for dealing with generic ranges and also
- // collections of ranges, or collections of ranges that have associated
- // data.
- //----------------------------------------------------------------------
-
- //----------------------------------------------------------------------
- // A simple range class where you get to define the type of the range
- // base "B", and the type used for the range byte size "S".
- //----------------------------------------------------------------------
- template <typename B, typename S>
- struct Range
- {
- typedef B BaseType;
- typedef S SizeType;
-
- BaseType base;
- SizeType size;
-
- Range () :
- base (0),
- size (0)
- {
- }
-
- Range (BaseType b, SizeType s) :
- base (b),
- size (s)
- {
- }
-
- void
- Clear (BaseType b = 0)
- {
- base = b;
- size = 0;
- }
-
- // Set the start value for the range, and keep the same size
- BaseType
- GetRangeBase () const
- {
- return base;
- }
-
- void
- SetRangeBase (BaseType b)
- {
- base = b;
- }
-
- void
- Slide (BaseType slide)
- {
- base += slide;
- }
-
- BaseType
- GetRangeEnd () const
- {
- return base + size;
- }
-
- void
- SetRangeEnd (BaseType end)
- {
- if (end > base)
- size = end - base;
- else
- size = 0;
- }
-
- SizeType
- GetByteSize () const
- {
- return size;
- }
-
- void
- SetByteSize (SizeType s)
- {
- size = s;
- }
-
- bool
- IsValid() const
- {
- return size > 0;
- }
-
- bool
- Contains (BaseType r) const
- {
- return (GetRangeBase() <= r) && (r < GetRangeEnd());
- }
-
- bool
- ContainsEndInclusive (BaseType r) const
- {
- return (GetRangeBase() <= r) && (r <= GetRangeEnd());
- }
-
- bool
- Contains (const Range& range) const
- {
- return Contains(range.GetRangeBase()) && ContainsEndInclusive(range.GetRangeEnd());
- }
-
- // Returns true if the two ranges adjoing or intersect
- bool
- DoesAdjoinOrIntersect (const Range &rhs) const
- {
- const BaseType lhs_base = this->GetRangeBase();
- const BaseType rhs_base = rhs.GetRangeBase();
- const BaseType lhs_end = this->GetRangeEnd();
- const BaseType rhs_end = rhs.GetRangeEnd();
- bool result = (lhs_base <= rhs_end) && (lhs_end >= rhs_base);
- return result;
- }
-
- // Returns true if the two ranges intersect
- bool
- DoesIntersect (const Range &rhs) const
- {
- const BaseType lhs_base = this->GetRangeBase();
- const BaseType rhs_base = rhs.GetRangeBase();
- const BaseType lhs_end = this->GetRangeEnd();
- const BaseType rhs_end = rhs.GetRangeEnd();
- bool result = (lhs_base < rhs_end) && (lhs_end > rhs_base);
- return result;
- }
-
- bool
- operator < (const Range &rhs) const
- {
- if (base == rhs.base)
- return size < rhs.size;
- return base < rhs.base;
- }
-
- bool
- operator == (const Range &rhs) const
- {
- return base == rhs.base && size == rhs.size;
- }
-
- bool
- operator != (const Range &rhs) const
- {
- return base != rhs.base || size != rhs.size;
- }
- };
-
- //----------------------------------------------------------------------
- // A range array class where you get to define the type of the ranges
- // that the collection contains.
- //----------------------------------------------------------------------
-
- template <typename B, typename S, unsigned N>
- class RangeArray
- {
- public:
- typedef B BaseType;
- typedef S SizeType;
- typedef Range<B,S> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
-
- RangeArray() = default;
-
- ~RangeArray() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Append (B base, S size)
- {
- m_entries.emplace_back(base, size);
- }
-
- bool
- RemoveEntrtAtIndex (uint32_t idx)
- {
- if (idx < m_entries.size())
- {
- m_entries.erase (m_entries.begin() + idx);
- return true;
- }
- return false;
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
-
- void
- CombineConsecutiveRanges ()
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- // Can't combine if ranges if we have zero or one range
- if (m_entries.size() > 1)
- {
- // The list should be sorted prior to calling this function
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- minimal_ranges.back().SetRangeEnd (std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
- }
-
- BaseType
- GetMinRangeBase (BaseType fail_value) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // first range's base
- return m_entries.front().GetRangeBase();
- }
-
- BaseType
- GetMaxRangeEnd (BaseType fail_value) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // last range's end
- return m_entries.back().GetRangeEnd();
- }
-
- void
- Slide (BaseType slide)
- {
- typename Collection::iterator pos, end;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- pos->Slide (slide);
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
- }
- return UINT32_MAX;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- protected:
- Collection m_entries;
- };
-
- template <typename B, typename S>
- class RangeVector
- {
- public:
- typedef B BaseType;
- typedef S SizeType;
- typedef Range<B,S> Entry;
- typedef std::vector<Entry> Collection;
-
- RangeVector() = default;
-
- ~RangeVector() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Append (B base, S size)
- {
- m_entries.emplace_back(base, size);
- }
-
- bool
- RemoveEntrtAtIndex (uint32_t idx)
- {
- if (idx < m_entries.size())
- {
- m_entries.erase (m_entries.begin() + idx);
- return true;
- }
- return false;
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
-
- void
- CombineConsecutiveRanges ()
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- // Can't combine if ranges if we have zero or one range
- if (m_entries.size() > 1)
- {
- // The list should be sorted prior to calling this function
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- minimal_ranges.back().SetRangeEnd (std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
- }
-
- BaseType
- GetMinRangeBase (BaseType fail_value) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // first range's base
- return m_entries.front().GetRangeBase();
- }
-
- BaseType
- GetMaxRangeEnd (BaseType fail_value) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the
- // last range's end
- return m_entries.back().GetRangeEnd();
- }
-
- void
- Slide (BaseType slide)
- {
- typename Collection::iterator pos, end;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- pos->Slide (slide);
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- void
- Reserve (typename Collection::size_type size)
- {
- m_entries.reserve (size);
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
- }
- return UINT32_MAX;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- protected:
- Collection m_entries;
- };
-
- //----------------------------------------------------------------------
- // A simple range with data class where you get to define the type of
- // the range base "B", the type used for the range byte size "S", and
- // the type for the associated data "T".
- //----------------------------------------------------------------------
- template <typename B, typename S, typename T>
- struct RangeData : public Range<B,S>
- {
- typedef T DataType;
-
- DataType data;
-
- RangeData () :
- Range<B,S> (),
- data ()
- {
- }
-
- RangeData (B base, S size) :
- Range<B,S> (base, size),
- data ()
- {
- }
-
- RangeData (B base, S size, DataType d) :
- Range<B,S> (base, size),
- data (d)
- {
- }
-
- bool
- operator < (const RangeData &rhs) const
- {
- if (this->base == rhs.base)
- {
- if (this->size == rhs.size)
- return this->data < rhs.data;
- else
- return this->size < rhs.size;
- }
- return this->base < rhs.base;
- }
-
- bool
- operator == (const RangeData &rhs) const
- {
- return this->GetRangeBase() == rhs.GetRangeBase() &&
- this->GetByteSize() == rhs.GetByteSize() &&
- this->data == rhs.data;
- }
-
- bool
- operator != (const RangeData &rhs) const
- {
- return this->GetRangeBase() != rhs.GetRangeBase() ||
- this->GetByteSize() != rhs.GetByteSize() ||
- this->data != rhs.data;
- }
- };
-
- template <typename B, typename S, typename T, unsigned N>
- class RangeDataArray
- {
- public:
- typedef RangeData<B,S,T> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
-
- RangeDataArray() = default;
-
- ~RangeDataArray() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
-
- void
- CombineConsecutiveEntriesWithEqualData ()
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- minimal_ranges.back().SetRangeEnd (pos->GetRangeEnd());
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
- }
- return UINT32_MAX;
- }
-
- Entry *
- FindEntryThatContains (B addr)
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::iterator begin = m_entries.begin();
- typename Collection::iterator end = m_entries.end();
- typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- protected:
- Collection m_entries;
- };
-
- // Same as RangeDataArray, but uses std::vector as to not
- // require static storage of N items in the class itself
- template <typename B, typename S, typename T>
- class RangeDataVector
- {
- public:
- typedef RangeData<B,S,T> Entry;
- typedef std::vector<Entry> Collection;
-
- RangeDataVector() = default;
-
- ~RangeDataVector() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
-
- void
- CombineConsecutiveEntriesWithEqualData ()
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine)
- {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && prev->data == pos->data)
- minimal_ranges.back().SetRangeEnd (pos->GetRangeEnd());
- else
- minimal_ranges.push_back (*pos);
- }
- // Use the swap technique in case our new vector is much smaller.
- // We must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap (minimal_ranges);
- }
- }
-
- // Calculate the byte size of ranges with zero byte sizes by finding
- // the next entry with a base address > the current base address
- void
- CalculateSizesOfZeroByteSizeRanges (S full_size = 0)
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator next;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- {
- if (pos->GetByteSize() == 0)
- {
- // Watch out for multiple entries with same address and make sure
- // we find an entry that is greater than the current base address
- // before we use that for the size
- auto curr_base = pos->GetRangeBase();
- for (next = pos + 1; next != end; ++next)
- {
- auto next_base = next->GetRangeBase();
- if (next_base > curr_base)
- {
- pos->SetByteSize (next_base - curr_base);
- break;
- }
- }
- if (next == end && full_size > curr_base)
- pos->SetByteSize (full_size - curr_base);
- }
- }
- }
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- void
- Reserve (typename Collection::size_type size)
- {
- m_entries.resize (size);
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- Entry *
- GetMutableEntryAtIndex (size_t i)
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t
- FindEntryIndexThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry (addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end && pos->Contains(addr))
- return std::distance (begin, pos);
- }
- return UINT32_MAX;
- }
-
- uint32_t
- FindEntryIndexesThatContain(B addr, std::vector<uint32_t> &indexes) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
-
- if (!m_entries.empty())
- {
- typename Collection::const_iterator pos;
- for (const auto &entry : m_entries)
- {
- if (entry.Contains(addr))
- indexes.push_back(entry.data);
- }
- }
- return indexes.size() ;
- }
-
- Entry *
- FindEntryThatContains (B addr)
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::iterator begin = m_entries.begin();
- typename Collection::iterator end = m_entries.end();
- typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end && pos->Contains(addr))
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.SetRangeBase(addr);
- entry.SetByteSize(1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end && pos->Contains(addr))
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry *
- FindEntryThatContains (const Entry &range) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
-
- while(pos != begin && pos[-1].Contains(range))
- --pos;
-
- if (pos != end && pos->Contains(range))
- return &(*pos);
- }
- return nullptr;
- }
-
- const Entry*
- FindEntryStartsAt (B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if (!m_entries.empty())
- {
- auto begin = m_entries.begin(), end = m_entries.end();
- auto pos = std::lower_bound (begin, end, Entry(addr, 1), BaseLessThan);
- if (pos != end && pos->base == addr)
- return &(*pos);
- }
- return nullptr;
- }
-
- // This method will return the entry that contains the given address, or the
- // entry following that address. If you give it an address of 0 and the first
- // entry starts at address 0x100, you will get the entry at 0x100.
- //
- // For most uses, FindEntryThatContains is the correct one to use, this is a
- // less commonly needed behavior. It was added for core file memory regions,
- // where we want to present a gap in the memory regions as a distinct region,
- // so we need to know the start address of the next memory section that exists.
- const Entry *
- FindEntryThatContainsOrFollows(B addr) const
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- if (!m_entries.empty())
- {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos =
- std::lower_bound(m_entries.begin(), end, addr, [](const Entry &lhs, B rhs_base) -> bool {
- return lhs.GetRangeEnd() <= rhs_base;
- });
-
- while (pos != begin && pos[-1].Contains(addr))
- --pos;
-
- if (pos != end)
- return &(*pos);
- }
- return nullptr;
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- protected:
- Collection m_entries;
- };
-
- //----------------------------------------------------------------------
- // A simple range with data class where you get to define the type of
- // the range base "B", the type used for the range byte size "S", and
- // the type for the associated data "T".
- //----------------------------------------------------------------------
- template <typename B, typename T>
- struct AddressData
- {
- typedef B BaseType;
- typedef T DataType;
-
- BaseType addr;
- DataType data;
-
- AddressData () :
- addr (),
- data ()
- {
- }
-
- AddressData (B a, DataType d) :
- addr (a),
- data (d)
- {
- }
-
- bool
- operator < (const AddressData &rhs) const
- {
- if (this->addr == rhs.addr)
- return this->data < rhs.data;
- return this->addr < rhs.addr;
- }
-
- bool
- operator == (const AddressData &rhs) const
- {
- return this->addr == rhs.addr &&
- this->data == rhs.data;
- }
-
- bool
- operator != (const AddressData &rhs) const
- {
- return this->addr != rhs.addr ||
- this->data == rhs.data;
- }
- };
-
- template <typename B, typename T, unsigned N>
- class AddressDataArray
- {
- public:
- typedef AddressData<B,T> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
-
- AddressDataArray() = default;
-
- ~AddressDataArray() = default;
-
- void
- Append (const Entry &entry)
- {
- m_entries.push_back (entry);
- }
-
- void
- Sort ()
- {
- if (m_entries.size() > 1)
- std::stable_sort (m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool
- IsSorted () const
- {
- typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++)
- {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
-
- void
- Clear ()
- {
- m_entries.clear();
- }
-
- bool
- IsEmpty () const
- {
- return m_entries.empty();
- }
-
- size_t
- GetSize () const
- {
- return m_entries.size();
- }
-
- const Entry *
- GetEntryAtIndex (size_t i) const
- {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this function
- const Entry &
- GetEntryRef (size_t i) const
- {
- return m_entries[i];
- }
-
- static bool
- BaseLessThan (const Entry& lhs, const Entry& rhs)
- {
- return lhs.addr < rhs.addr;
- }
-
- Entry *
- FindEntry (B addr, bool exact_match_only)
- {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert (IsSorted());
-#endif
- if ( !m_entries.empty() )
- {
- Entry entry;
- entry.addr = addr;
- typename Collection::iterator begin = m_entries.begin();
- typename Collection::iterator end = m_entries.end();
- typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
-
- while(pos != begin && pos[-1].addr == addr)
- --pos;
-
- if (pos != end)
- {
- if (pos->addr == addr || !exact_match_only)
- return &(*pos);
- }
- }
- return nullptr;
- }
-
- const Entry *
- FindNextEntry (const Entry *entry)
- {
- if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end())
- return entry + 1;
- return nullptr;
- }
-
- Entry *
- Back()
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- const Entry *
- Back() const
- {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
- protected:
- Collection m_entries;
- };
+//----------------------------------------------------------------------
+// Templatized classes for dealing with generic ranges and also
+// collections of ranges, or collections of ranges that have associated
+// data.
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// A simple range class where you get to define the type of the range
+// base "B", and the type used for the range byte size "S".
+//----------------------------------------------------------------------
+template <typename B, typename S> struct Range {
+ typedef B BaseType;
+ typedef S SizeType;
+
+ BaseType base;
+ SizeType size;
+
+ Range() : base(0), size(0) {}
+
+ Range(BaseType b, SizeType s) : base(b), size(s) {}
+
+ void Clear(BaseType b = 0) {
+ base = b;
+ size = 0;
+ }
+
+ // Set the start value for the range, and keep the same size
+ BaseType GetRangeBase() const { return base; }
+
+ void SetRangeBase(BaseType b) { base = b; }
+
+ void Slide(BaseType slide) { base += slide; }
+
+ BaseType GetRangeEnd() const { return base + size; }
+
+ void SetRangeEnd(BaseType end) {
+ if (end > base)
+ size = end - base;
+ else
+ size = 0;
+ }
+
+ SizeType GetByteSize() const { return size; }
+
+ void SetByteSize(SizeType s) { size = s; }
+
+ bool IsValid() const { return size > 0; }
+
+ bool Contains(BaseType r) const {
+ return (GetRangeBase() <= r) && (r < GetRangeEnd());
+ }
+
+ bool ContainsEndInclusive(BaseType r) const {
+ return (GetRangeBase() <= r) && (r <= GetRangeEnd());
+ }
+
+ bool Contains(const Range &range) const {
+ return Contains(range.GetRangeBase()) &&
+ ContainsEndInclusive(range.GetRangeEnd());
+ }
+
+ // Returns true if the two ranges adjoing or intersect
+ bool DoesAdjoinOrIntersect(const Range &rhs) const {
+ const BaseType lhs_base = this->GetRangeBase();
+ const BaseType rhs_base = rhs.GetRangeBase();
+ const BaseType lhs_end = this->GetRangeEnd();
+ const BaseType rhs_end = rhs.GetRangeEnd();
+ bool result = (lhs_base <= rhs_end) && (lhs_end >= rhs_base);
+ return result;
+ }
+
+ // Returns true if the two ranges intersect
+ bool DoesIntersect(const Range &rhs) const {
+ const BaseType lhs_base = this->GetRangeBase();
+ const BaseType rhs_base = rhs.GetRangeBase();
+ const BaseType lhs_end = this->GetRangeEnd();
+ const BaseType rhs_end = rhs.GetRangeEnd();
+ bool result = (lhs_base < rhs_end) && (lhs_end > rhs_base);
+ return result;
+ }
+
+ bool operator<(const Range &rhs) const {
+ if (base == rhs.base)
+ return size < rhs.size;
+ return base < rhs.base;
+ }
+
+ bool operator==(const Range &rhs) const {
+ return base == rhs.base && size == rhs.size;
+ }
+
+ bool operator!=(const Range &rhs) const {
+ return base != rhs.base || size != rhs.size;
+ }
+};
+
+//----------------------------------------------------------------------
+// A range array class where you get to define the type of the ranges
+// that the collection contains.
+//----------------------------------------------------------------------
+
+template <typename B, typename S, unsigned N> class RangeArray {
+public:
+ typedef B BaseType;
+ typedef S SizeType;
+ typedef Range<B, S> Entry;
+ typedef llvm::SmallVector<Entry, N> Collection;
+
+ RangeArray() = default;
+
+ ~RangeArray() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Append(B base, S size) { m_entries.emplace_back(base, size); }
+
+ bool RemoveEntrtAtIndex(uint32_t idx) {
+ if (idx < m_entries.size()) {
+ m_entries.erase(m_entries.begin() + idx);
+ return true;
+ }
+ return false;
+ }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
+
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
+#endif
+
+ void CombineConsecutiveRanges() {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ // Can't combine if ranges if we have zero or one range
+ if (m_entries.size() > 1) {
+ // The list should be sorted prior to calling this function
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
+ minimal_ranges.back().SetRangeEnd(
+ std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+ }
+
+ BaseType GetMinRangeBase(BaseType fail_value) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // first range's base
+ return m_entries.front().GetRangeBase();
+ }
+
+ BaseType GetMaxRangeEnd(BaseType fail_value) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // last range's end
+ return m_entries.back().GetRangeEnd();
+ }
+
+ void Slide(BaseType slide) {
+ typename Collection::iterator pos, end;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
+ pos->Slide(slide);
+ }
+
+ void Clear() { m_entries.clear(); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return std::distance(begin, pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ }
+ return UINT32_MAX;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ if (pos != end && pos->Contains(range)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(range)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+protected:
+ Collection m_entries;
+};
+
+template <typename B, typename S> class RangeVector {
+public:
+ typedef B BaseType;
+ typedef S SizeType;
+ typedef Range<B, S> Entry;
+ typedef std::vector<Entry> Collection;
+
+ RangeVector() = default;
+
+ ~RangeVector() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Append(B base, S size) { m_entries.emplace_back(base, size); }
+
+ bool RemoveEntrtAtIndex(uint32_t idx) {
+ if (idx < m_entries.size()) {
+ m_entries.erase(m_entries.begin() + idx);
+ return true;
+ }
+ return false;
+ }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
+
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
+#endif
+
+ void CombineConsecutiveRanges() {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ // Can't combine if ranges if we have zero or one range
+ if (m_entries.size() > 1) {
+ // The list should be sorted prior to calling this function
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
+ minimal_ranges.back().SetRangeEnd(
+ std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+ }
+
+ BaseType GetMinRangeBase(BaseType fail_value) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // first range's base
+ return m_entries.front().GetRangeBase();
+ }
+
+ BaseType GetMaxRangeEnd(BaseType fail_value) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (m_entries.empty())
+ return fail_value;
+ // m_entries must be sorted, so if we aren't empty, we grab the
+ // last range's end
+ return m_entries.back().GetRangeEnd();
+ }
+
+ void Slide(BaseType slide) {
+ typename Collection::iterator pos, end;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
+ pos->Slide(slide);
+ }
+
+ void Clear() { m_entries.clear(); }
+
+ void Reserve(typename Collection::size_type size) { m_entries.reserve(size); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return std::distance(begin, pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ }
+ return UINT32_MAX;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ if (pos != end && pos->Contains(range)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(range)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+protected:
+ Collection m_entries;
+};
+
+//----------------------------------------------------------------------
+// A simple range with data class where you get to define the type of
+// the range base "B", the type used for the range byte size "S", and
+// the type for the associated data "T".
+//----------------------------------------------------------------------
+template <typename B, typename S, typename T>
+struct RangeData : public Range<B, S> {
+ typedef T DataType;
+
+ DataType data;
+
+ RangeData() : Range<B, S>(), data() {}
+
+ RangeData(B base, S size) : Range<B, S>(base, size), data() {}
+
+ RangeData(B base, S size, DataType d) : Range<B, S>(base, size), data(d) {}
+
+ bool operator<(const RangeData &rhs) const {
+ if (this->base == rhs.base) {
+ if (this->size == rhs.size)
+ return this->data < rhs.data;
+ else
+ return this->size < rhs.size;
+ }
+ return this->base < rhs.base;
+ }
+
+ bool operator==(const RangeData &rhs) const {
+ return this->GetRangeBase() == rhs.GetRangeBase() &&
+ this->GetByteSize() == rhs.GetByteSize() && this->data == rhs.data;
+ }
+
+ bool operator!=(const RangeData &rhs) const {
+ return this->GetRangeBase() != rhs.GetRangeBase() ||
+ this->GetByteSize() != rhs.GetByteSize() || this->data != rhs.data;
+ }
+};
+
+template <typename B, typename S, typename T, unsigned N> class RangeDataArray {
+public:
+ typedef RangeData<B, S, T> Entry;
+ typedef llvm::SmallVector<Entry, N> Collection;
+
+ RangeDataArray() = default;
+
+ ~RangeDataArray() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
+
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
+#endif
+
+ void CombineConsecutiveEntriesWithEqualData() {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && prev->data == pos->data) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->data == pos->data)
+ minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd());
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+
+ void Clear() { m_entries.clear(); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return std::distance(begin, pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ }
+ return UINT32_MAX;
+ }
+
+ Entry *FindEntryThatContains(B addr) {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::iterator begin = m_entries.begin();
+ typename Collection::iterator end = m_entries.end();
+ typename Collection::iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ if (pos != end && pos->Contains(addr)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(addr)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ if (pos != end && pos->Contains(range)) {
+ return &(*pos);
+ } else if (pos != begin) {
+ --pos;
+ if (pos->Contains(range)) {
+ return &(*pos);
+ }
+ }
+ }
+ return nullptr;
+ }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+protected:
+ Collection m_entries;
+};
+
+// Same as RangeDataArray, but uses std::vector as to not
+// require static storage of N items in the class itself
+template <typename B, typename S, typename T> class RangeDataVector {
+public:
+ typedef RangeData<B, S, T> Entry;
+ typedef std::vector<Entry> Collection;
+
+ RangeDataVector() = default;
+
+ ~RangeDataVector() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
+
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
+#endif
+
+ void CombineConsecutiveEntriesWithEqualData() {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator prev;
+ bool can_combine = false;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && prev->data == pos->data) {
+ can_combine = true;
+ break;
+ }
+ }
+
+ // We we can combine at least one entry, then we make a new collection
+ // and populate it accordingly, and then swap it into place.
+ if (can_combine) {
+ Collection minimal_ranges;
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
+ pos != end; prev = pos++) {
+ if (prev != end && prev->data == pos->data)
+ minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd());
+ else
+ minimal_ranges.push_back(*pos);
+ }
+ // Use the swap technique in case our new vector is much smaller.
+ // We must swap when using the STL because std::vector objects never
+ // release or reduce the memory once it has been allocated/reserved.
+ m_entries.swap(minimal_ranges);
+ }
+ }
+
+ // Calculate the byte size of ranges with zero byte sizes by finding
+ // the next entry with a base address > the current base address
+ void CalculateSizesOfZeroByteSizeRanges(S full_size = 0) {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ typename Collection::iterator pos;
+ typename Collection::iterator end;
+ typename Collection::iterator next;
+ for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) {
+ if (pos->GetByteSize() == 0) {
+ // Watch out for multiple entries with same address and make sure
+ // we find an entry that is greater than the current base address
+ // before we use that for the size
+ auto curr_base = pos->GetRangeBase();
+ for (next = pos + 1; next != end; ++next) {
+ auto next_base = next->GetRangeBase();
+ if (next_base > curr_base) {
+ pos->SetByteSize(next_base - curr_base);
+ break;
+ }
+ }
+ if (next == end && full_size > curr_base)
+ pos->SetByteSize(full_size - curr_base);
+ }
+ }
+ }
+
+ void Clear() { m_entries.clear(); }
+
+ void Reserve(typename Collection::size_type size) { m_entries.resize(size); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ Entry *GetMutableEntryAtIndex(size_t i) {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.GetRangeBase() < rhs.GetRangeBase();
+ }
+
+ uint32_t FindEntryIndexThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry(addr, 1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end && pos->Contains(addr))
+ return std::distance(begin, pos);
+ }
+ return UINT32_MAX;
+ }
+
+ uint32_t FindEntryIndexesThatContain(B addr,
+ std::vector<uint32_t> &indexes) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator pos;
+ for (const auto &entry : m_entries) {
+ if (entry.Contains(addr))
+ indexes.push_back(entry.data);
+ }
+ }
+ return indexes.size();
+ }
+
+ Entry *FindEntryThatContains(B addr) {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::iterator begin = m_entries.begin();
+ typename Collection::iterator end = m_entries.end();
+ typename Collection::iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end && pos->Contains(addr))
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.SetRangeBase(addr);
+ entry.SetByteSize(1);
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end && pos->Contains(addr))
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryThatContains(const Entry &range) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(begin, end, range, BaseLessThan);
+
+ while (pos != begin && pos[-1].Contains(range))
+ --pos;
+
+ if (pos != end && pos->Contains(range))
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ const Entry *FindEntryStartsAt(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ auto begin = m_entries.begin(), end = m_entries.end();
+ auto pos = std::lower_bound(begin, end, Entry(addr, 1), BaseLessThan);
+ if (pos != end && pos->base == addr)
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ // This method will return the entry that contains the given address, or the
+ // entry following that address. If you give it an address of 0 and the first
+ // entry starts at address 0x100, you will get the entry at 0x100.
+ //
+ // For most uses, FindEntryThatContains is the correct one to use, this is a
+ // less commonly needed behavior. It was added for core file memory regions,
+ // where we want to present a gap in the memory regions as a distinct region,
+ // so we need to know the start address of the next memory section that
+ // exists.
+ const Entry *FindEntryThatContainsOrFollows(B addr) const {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ typename Collection::const_iterator begin = m_entries.begin();
+ typename Collection::const_iterator end = m_entries.end();
+ typename Collection::const_iterator pos =
+ std::lower_bound(m_entries.begin(), end, addr,
+ [](const Entry &lhs, B rhs_base) -> bool {
+ return lhs.GetRangeEnd() <= rhs_base;
+ });
+
+ while (pos != begin && pos[-1].Contains(addr))
+ --pos;
+
+ if (pos != end)
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+protected:
+ Collection m_entries;
+};
+
+//----------------------------------------------------------------------
+// A simple range with data class where you get to define the type of
+// the range base "B", the type used for the range byte size "S", and
+// the type for the associated data "T".
+//----------------------------------------------------------------------
+template <typename B, typename T> struct AddressData {
+ typedef B BaseType;
+ typedef T DataType;
+
+ BaseType addr;
+ DataType data;
+
+ AddressData() : addr(), data() {}
+
+ AddressData(B a, DataType d) : addr(a), data(d) {}
+
+ bool operator<(const AddressData &rhs) const {
+ if (this->addr == rhs.addr)
+ return this->data < rhs.data;
+ return this->addr < rhs.addr;
+ }
+
+ bool operator==(const AddressData &rhs) const {
+ return this->addr == rhs.addr && this->data == rhs.data;
+ }
+
+ bool operator!=(const AddressData &rhs) const {
+ return this->addr != rhs.addr || this->data == rhs.data;
+ }
+};
+
+template <typename B, typename T, unsigned N> class AddressDataArray {
+public:
+ typedef AddressData<B, T> Entry;
+ typedef llvm::SmallVector<Entry, N> Collection;
+
+ AddressDataArray() = default;
+
+ ~AddressDataArray() = default;
+
+ void Append(const Entry &entry) { m_entries.push_back(entry); }
+
+ void Sort() {
+ if (m_entries.size() > 1)
+ std::stable_sort(m_entries.begin(), m_entries.end());
+ }
+
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ bool IsSorted() const {
+ typename Collection::const_iterator pos, end, prev;
+ // First we determine if we can combine any of the Entry objects so we
+ // don't end up allocating and making a new collection for no reason
+ for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
+ prev = pos++) {
+ if (prev != end && *pos < *prev)
+ return false;
+ }
+ return true;
+ }
+#endif
+
+ void Clear() { m_entries.clear(); }
+
+ bool IsEmpty() const { return m_entries.empty(); }
+
+ size_t GetSize() const { return m_entries.size(); }
+
+ const Entry *GetEntryAtIndex(size_t i) const {
+ return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
+ }
+
+ // Clients must ensure that "i" is a valid index prior to calling this
+ // function
+ const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
+
+ static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
+ return lhs.addr < rhs.addr;
+ }
+
+ Entry *FindEntry(B addr, bool exact_match_only) {
+#ifdef ASSERT_RANGEMAP_ARE_SORTED
+ assert(IsSorted());
+#endif
+ if (!m_entries.empty()) {
+ Entry entry;
+ entry.addr = addr;
+ typename Collection::iterator begin = m_entries.begin();
+ typename Collection::iterator end = m_entries.end();
+ typename Collection::iterator pos =
+ std::lower_bound(begin, end, entry, BaseLessThan);
+
+ while (pos != begin && pos[-1].addr == addr)
+ --pos;
+
+ if (pos != end) {
+ if (pos->addr == addr || !exact_match_only)
+ return &(*pos);
+ }
+ }
+ return nullptr;
+ }
+
+ const Entry *FindNextEntry(const Entry *entry) {
+ if (entry >= &*m_entries.begin() && entry + 1 < &*m_entries.end())
+ return entry + 1;
+ return nullptr;
+ }
+
+ Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
+
+ const Entry *Back() const {
+ return (m_entries.empty() ? nullptr : &m_entries.back());
+ }
+
+protected:
+ Collection m_entries;
+};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/RegisterValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RegisterValue.h (original)
+++ lldb/trunk/include/lldb/Core/RegisterValue.h Tue Sep 6 15:57:50 2016
@@ -18,376 +18,258 @@
#include "llvm/ADT/APInt.h"
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-private.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Core/Scalar.h"
+#include "lldb/Host/Endian.h"
+#include "lldb/lldb-private.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
- class RegisterValue
- {
- public:
- enum
- {
- kMaxRegisterByteSize = 32u
- };
-
- enum Type
- {
- eTypeInvalid,
- eTypeUInt8,
- eTypeUInt16,
- eTypeUInt32,
- eTypeUInt64,
- eTypeUInt128,
- eTypeFloat,
- eTypeDouble,
- eTypeLongDouble,
- eTypeBytes
- };
-
- RegisterValue () :
- m_type (eTypeInvalid),
- m_scalar ((unsigned long)0)
- {
- }
-
- explicit
- RegisterValue (uint8_t inst) :
- m_type (eTypeUInt8)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (uint16_t inst) :
- m_type (eTypeUInt16)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (uint32_t inst) :
- m_type (eTypeUInt32)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (uint64_t inst) :
- m_type (eTypeUInt64)
- {
- m_scalar = inst;
- }
-
- explicit
- RegisterValue (llvm::APInt inst) :
- m_type (eTypeUInt128)
- {
- m_scalar = llvm::APInt(inst);
- }
-
- explicit
- RegisterValue (float value) :
- m_type (eTypeFloat)
- {
- m_scalar = value;
- }
-
- explicit
- RegisterValue (double value) :
- m_type (eTypeDouble)
- {
- m_scalar = value;
- }
-
- explicit
- RegisterValue (long double value) :
- m_type (eTypeLongDouble)
- {
- m_scalar = value;
- }
-
- explicit
- RegisterValue (uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
- {
- SetBytes (bytes, length, byte_order);
- }
-
- RegisterValue::Type
- GetType () const
- {
- return m_type;
- }
-
- bool
- CopyValue (const RegisterValue &rhs);
-
- void
- SetType (RegisterValue::Type type)
- {
- m_type = type;
- }
-
- RegisterValue::Type
- SetType (const RegisterInfo *reg_info);
-
- bool
- GetData (DataExtractor &data) const;
-
- // Copy the register value from this object into a buffer in "dst"
- // and obey the "dst_byte_order" when copying the data. Also watch out
- // in case "dst_len" is longer or shorter than the register value
- // described by "reg_info" and only copy the least significant bytes
- // of the register value, or pad the destination with zeroes if the
- // register byte size is shorter that "dst_len" (all while correctly
- // abiding the "dst_byte_order"). Returns the number of bytes copied
- // into "dst".
- uint32_t
- GetAsMemoryData (const RegisterInfo *reg_info,
- void *dst,
- uint32_t dst_len,
- lldb::ByteOrder dst_byte_order,
- Error &error) const;
-
- uint32_t
- SetFromMemoryData (const RegisterInfo *reg_info,
- const void *src,
- uint32_t src_len,
- lldb::ByteOrder src_byte_order,
- Error &error);
-
- bool
- GetScalarValue (Scalar &scalar) const;
-
- uint8_t
- GetAsUInt8(uint8_t fail_value = UINT8_MAX, bool *success_ptr = nullptr) const
- {
- if (m_type == eTypeUInt8)
- {
- if (success_ptr)
- *success_ptr = true;
- return m_scalar.UChar(fail_value);
- }
- if (success_ptr)
- *success_ptr = true;
- return fail_value;
- }
-
- uint16_t
- GetAsUInt16(uint16_t fail_value = UINT16_MAX, bool *success_ptr = nullptr) const;
-
- uint32_t
- GetAsUInt32(uint32_t fail_value = UINT32_MAX, bool *success_ptr = nullptr) const;
-
- uint64_t
- GetAsUInt64(uint64_t fail_value = UINT64_MAX, bool *success_ptr = nullptr) const;
-
- llvm::APInt
- GetAsUInt128(const llvm::APInt& fail_value, bool *success_ptr = nullptr) const;
-
- float
- GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const;
-
- double
- GetAsDouble(double fail_value = 0.0, bool *success_ptr = nullptr) const;
-
- long double
- GetAsLongDouble(long double fail_value = 0.0, bool *success_ptr = nullptr) const;
-
- void
- SetValueToInvalid ()
- {
- m_type = eTypeInvalid;
- }
-
- bool
- ClearBit (uint32_t bit);
-
- bool
- SetBit (uint32_t bit);
-
- bool
- operator == (const RegisterValue &rhs) const;
-
- bool
- operator != (const RegisterValue &rhs) const;
-
- void
- operator = (uint8_t uint)
- {
- m_type = eTypeUInt8;
- m_scalar = uint;
- }
-
- void
- operator = (uint16_t uint)
- {
- m_type = eTypeUInt16;
- m_scalar = uint;
- }
-
- void
- operator = (uint32_t uint)
- {
- m_type = eTypeUInt32;
- m_scalar = uint;
- }
-
- void
- operator = (uint64_t uint)
- {
- m_type = eTypeUInt64;
- m_scalar = uint;
- }
-
- void
- operator = (llvm::APInt uint)
- {
- m_type = eTypeUInt128;
- m_scalar = llvm::APInt(uint);
- }
-
- void
- operator = (float f)
- {
- m_type = eTypeFloat;
- m_scalar = f;
- }
-
- void
- operator = (double f)
- {
- m_type = eTypeDouble;
- m_scalar = f;
- }
-
- void
- operator = (long double f)
- {
- m_type = eTypeLongDouble;
- m_scalar = f;
- }
-
- void
- SetUInt8 (uint8_t uint)
- {
- m_type = eTypeUInt8;
- m_scalar = uint;
- }
-
- void
- SetUInt16 (uint16_t uint)
- {
- m_type = eTypeUInt16;
- m_scalar = uint;
- }
-
- void
- SetUInt32 (uint32_t uint, Type t = eTypeUInt32)
- {
- m_type = t;
- m_scalar = uint;
- }
-
- void
- SetUInt64 (uint64_t uint, Type t = eTypeUInt64)
- {
- m_type = t;
- m_scalar = uint;
- }
-
- void
- SetUInt128 (llvm::APInt uint)
- {
- m_type = eTypeUInt128;
- m_scalar = uint;
- }
-
- bool
- SetUInt (uint64_t uint, uint32_t byte_size);
-
- void
- SetFloat (float f)
- {
- m_type = eTypeFloat;
- m_scalar = f;
- }
-
- void
- SetDouble (double f)
- {
- m_type = eTypeDouble;
- m_scalar = f;
- }
-
- void
- SetLongDouble (long double f)
- {
- m_type = eTypeLongDouble;
- m_scalar = f;
- }
-
- void
- SetBytes (const void *bytes, size_t length, lldb::ByteOrder byte_order);
-
- bool
- SignExtend (uint32_t sign_bitpos);
-
- Error
- SetValueFromCString (const RegisterInfo *reg_info,
- const char *value_str);
-
- Error
- SetValueFromData (const RegisterInfo *reg_info,
- DataExtractor &data,
- lldb::offset_t offset,
- bool partial_data_ok);
-
- // The default value of 0 for reg_name_right_align_at means no alignment at all.
- bool
- Dump (Stream *s,
- const RegisterInfo *reg_info,
- bool prefix_with_name,
- bool prefix_with_alt_name,
- lldb::Format format,
- uint32_t reg_name_right_align_at = 0) const;
-
- const void *
- GetBytes () const;
-
- lldb::ByteOrder
- GetByteOrder () const
- {
- if (m_type == eTypeBytes)
- return buffer.byte_order;
- return endian::InlHostByteOrder();
- }
-
- uint32_t
- GetByteSize () const;
-
- static uint32_t
- GetMaxByteSize ()
- {
- return kMaxRegisterByteSize;
- }
-
- void
- Clear();
-
- protected:
- RegisterValue::Type m_type;
- Scalar m_scalar;
-
- struct
- {
- uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any register for any supported target.
- uint8_t length;
- lldb::ByteOrder byte_order;
- } buffer;
- };
+class RegisterValue {
+public:
+ enum { kMaxRegisterByteSize = 32u };
+
+ enum Type {
+ eTypeInvalid,
+ eTypeUInt8,
+ eTypeUInt16,
+ eTypeUInt32,
+ eTypeUInt64,
+ eTypeUInt128,
+ eTypeFloat,
+ eTypeDouble,
+ eTypeLongDouble,
+ eTypeBytes
+ };
+
+ RegisterValue() : m_type(eTypeInvalid), m_scalar((unsigned long)0) {}
+
+ explicit RegisterValue(uint8_t inst) : m_type(eTypeUInt8) { m_scalar = inst; }
+
+ explicit RegisterValue(uint16_t inst) : m_type(eTypeUInt16) {
+ m_scalar = inst;
+ }
+
+ explicit RegisterValue(uint32_t inst) : m_type(eTypeUInt32) {
+ m_scalar = inst;
+ }
+
+ explicit RegisterValue(uint64_t inst) : m_type(eTypeUInt64) {
+ m_scalar = inst;
+ }
+
+ explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) {
+ m_scalar = llvm::APInt(inst);
+ }
+
+ explicit RegisterValue(float value) : m_type(eTypeFloat) { m_scalar = value; }
+
+ explicit RegisterValue(double value) : m_type(eTypeDouble) {
+ m_scalar = value;
+ }
+
+ explicit RegisterValue(long double value) : m_type(eTypeLongDouble) {
+ m_scalar = value;
+ }
+
+ explicit RegisterValue(uint8_t *bytes, size_t length,
+ lldb::ByteOrder byte_order) {
+ SetBytes(bytes, length, byte_order);
+ }
+
+ RegisterValue::Type GetType() const { return m_type; }
+
+ bool CopyValue(const RegisterValue &rhs);
+
+ void SetType(RegisterValue::Type type) { m_type = type; }
+
+ RegisterValue::Type SetType(const RegisterInfo *reg_info);
+
+ bool GetData(DataExtractor &data) const;
+
+ // Copy the register value from this object into a buffer in "dst"
+ // and obey the "dst_byte_order" when copying the data. Also watch out
+ // in case "dst_len" is longer or shorter than the register value
+ // described by "reg_info" and only copy the least significant bytes
+ // of the register value, or pad the destination with zeroes if the
+ // register byte size is shorter that "dst_len" (all while correctly
+ // abiding the "dst_byte_order"). Returns the number of bytes copied
+ // into "dst".
+ uint32_t GetAsMemoryData(const RegisterInfo *reg_info, void *dst,
+ uint32_t dst_len, lldb::ByteOrder dst_byte_order,
+ Error &error) const;
+
+ uint32_t SetFromMemoryData(const RegisterInfo *reg_info, const void *src,
+ uint32_t src_len, lldb::ByteOrder src_byte_order,
+ Error &error);
+
+ bool GetScalarValue(Scalar &scalar) const;
+
+ uint8_t GetAsUInt8(uint8_t fail_value = UINT8_MAX,
+ bool *success_ptr = nullptr) const {
+ if (m_type == eTypeUInt8) {
+ if (success_ptr)
+ *success_ptr = true;
+ return m_scalar.UChar(fail_value);
+ }
+ if (success_ptr)
+ *success_ptr = true;
+ return fail_value;
+ }
+
+ uint16_t GetAsUInt16(uint16_t fail_value = UINT16_MAX,
+ bool *success_ptr = nullptr) const;
+
+ uint32_t GetAsUInt32(uint32_t fail_value = UINT32_MAX,
+ bool *success_ptr = nullptr) const;
+
+ uint64_t GetAsUInt64(uint64_t fail_value = UINT64_MAX,
+ bool *success_ptr = nullptr) const;
+
+ llvm::APInt GetAsUInt128(const llvm::APInt &fail_value,
+ bool *success_ptr = nullptr) const;
+
+ float GetAsFloat(float fail_value = 0.0f, bool *success_ptr = nullptr) const;
+
+ double GetAsDouble(double fail_value = 0.0,
+ bool *success_ptr = nullptr) const;
+
+ long double GetAsLongDouble(long double fail_value = 0.0,
+ bool *success_ptr = nullptr) const;
+
+ void SetValueToInvalid() { m_type = eTypeInvalid; }
+
+ bool ClearBit(uint32_t bit);
+
+ bool SetBit(uint32_t bit);
+
+ bool operator==(const RegisterValue &rhs) const;
+
+ bool operator!=(const RegisterValue &rhs) const;
+
+ void operator=(uint8_t uint) {
+ m_type = eTypeUInt8;
+ m_scalar = uint;
+ }
+
+ void operator=(uint16_t uint) {
+ m_type = eTypeUInt16;
+ m_scalar = uint;
+ }
+
+ void operator=(uint32_t uint) {
+ m_type = eTypeUInt32;
+ m_scalar = uint;
+ }
+
+ void operator=(uint64_t uint) {
+ m_type = eTypeUInt64;
+ m_scalar = uint;
+ }
+
+ void operator=(llvm::APInt uint) {
+ m_type = eTypeUInt128;
+ m_scalar = llvm::APInt(uint);
+ }
+
+ void operator=(float f) {
+ m_type = eTypeFloat;
+ m_scalar = f;
+ }
+
+ void operator=(double f) {
+ m_type = eTypeDouble;
+ m_scalar = f;
+ }
+
+ void operator=(long double f) {
+ m_type = eTypeLongDouble;
+ m_scalar = f;
+ }
+
+ void SetUInt8(uint8_t uint) {
+ m_type = eTypeUInt8;
+ m_scalar = uint;
+ }
+
+ void SetUInt16(uint16_t uint) {
+ m_type = eTypeUInt16;
+ m_scalar = uint;
+ }
+
+ void SetUInt32(uint32_t uint, Type t = eTypeUInt32) {
+ m_type = t;
+ m_scalar = uint;
+ }
+
+ void SetUInt64(uint64_t uint, Type t = eTypeUInt64) {
+ m_type = t;
+ m_scalar = uint;
+ }
+
+ void SetUInt128(llvm::APInt uint) {
+ m_type = eTypeUInt128;
+ m_scalar = uint;
+ }
+
+ bool SetUInt(uint64_t uint, uint32_t byte_size);
+
+ void SetFloat(float f) {
+ m_type = eTypeFloat;
+ m_scalar = f;
+ }
+
+ void SetDouble(double f) {
+ m_type = eTypeDouble;
+ m_scalar = f;
+ }
+
+ void SetLongDouble(long double f) {
+ m_type = eTypeLongDouble;
+ m_scalar = f;
+ }
+
+ void SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order);
+
+ bool SignExtend(uint32_t sign_bitpos);
+
+ Error SetValueFromCString(const RegisterInfo *reg_info,
+ const char *value_str);
+
+ Error SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data,
+ lldb::offset_t offset, bool partial_data_ok);
+
+ // The default value of 0 for reg_name_right_align_at means no alignment at
+ // all.
+ bool Dump(Stream *s, const RegisterInfo *reg_info, bool prefix_with_name,
+ bool prefix_with_alt_name, lldb::Format format,
+ uint32_t reg_name_right_align_at = 0) const;
+
+ const void *GetBytes() const;
+
+ lldb::ByteOrder GetByteOrder() const {
+ if (m_type == eTypeBytes)
+ return buffer.byte_order;
+ return endian::InlHostByteOrder();
+ }
+
+ uint32_t GetByteSize() const;
+
+ static uint32_t GetMaxByteSize() { return kMaxRegisterByteSize; }
+
+ void Clear();
+
+protected:
+ RegisterValue::Type m_type;
+ Scalar m_scalar;
+
+ struct {
+ uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any
+ // register for any supported target.
+ uint8_t length;
+ lldb::ByteOrder byte_order;
+ } buffer;
+};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/RegularExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegularExpression.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RegularExpression.h (original)
+++ lldb/trunk/include/lldb/Core/RegularExpression.h Tue Sep 6 15:57:50 2016
@@ -16,26 +16,20 @@
typedef llvm_regmatch_t regmatch_t;
typedef llvm_regex_t regex_t;
-inline int regcomp(llvm_regex_t * a, const char *b, int c)
-{
- return llvm_regcomp(a, b, c);
+inline int regcomp(llvm_regex_t *a, const char *b, int c) {
+ return llvm_regcomp(a, b, c);
}
-inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d)
-{
- return llvm_regerror(a, b, c, d);
+inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d) {
+ return llvm_regerror(a, b, c, d);
}
-inline int regexec(const llvm_regex_t * a, const char * b, size_t c,
- llvm_regmatch_t d [], int e)
-{
- return llvm_regexec(a, b, c, d, e);
+inline int regexec(const llvm_regex_t *a, const char *b, size_t c,
+ llvm_regmatch_t d[], int e) {
+ return llvm_regexec(a, b, c, d, e);
}
-inline void regfree(llvm_regex_t * a)
-{
- llvm_regfree(a);
-}
+inline void regfree(llvm_regex_t *a) { llvm_regfree(a); }
#else
#if __ANDROID_NDK__
#include <regex>
@@ -47,9 +41,8 @@ inline void regfree(llvm_regex_t * a)
#include <string>
#include <vector>
-namespace llvm
-{
- class StringRef;
+namespace llvm {
+class StringRef;
} // namespace llvm
namespace lldb_private {
@@ -62,182 +55,157 @@ namespace lldb_private {
/// \c regcomp(), \c regerror(), \c regexec(), and \c regfree() from
/// the header file in \c /usr/include/regex\.h.
//----------------------------------------------------------------------
-class RegularExpression
-{
+class RegularExpression {
public:
- class Match
- {
- public:
- Match (uint32_t max_matches) :
- m_matches ()
- {
- if (max_matches > 0)
- m_matches.resize(max_matches + 1);
- }
-
- void
- Clear()
- {
- const size_t num_matches = m_matches.size();
- regmatch_t invalid_match = { -1, -1 };
- for (size_t i=0; i<num_matches; ++i)
- m_matches[i] = invalid_match;
- }
-
- size_t
- GetSize () const
- {
- return m_matches.size();
- }
-
- regmatch_t *
- GetData ()
- {
- return (m_matches.empty() ? nullptr : m_matches.data());
- }
-
- bool
- GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const;
-
- bool
- GetMatchAtIndex (const char* s, uint32_t idx, llvm::StringRef& match_str) const;
-
- bool
- GetMatchSpanningIndices (const char* s, uint32_t idx1, uint32_t idx2, llvm::StringRef& match_str) const;
-
- protected:
- std::vector<regmatch_t> m_matches; ///< Where parenthesized subexpressions results are stored
- };
-
- //------------------------------------------------------------------
- /// Default constructor.
- ///
- /// The default constructor that initializes the object state such
- /// that it contains no compiled regular expression.
- //------------------------------------------------------------------
- RegularExpression ();
-
- explicit
- RegularExpression (const char* re);
-
- //------------------------------------------------------------------
- /// Destructor.
- ///
- /// Any previously compiled regular expression contained in this
- /// object will be freed.
- //------------------------------------------------------------------
- ~RegularExpression ();
-
- RegularExpression (const RegularExpression &rhs);
-
- const RegularExpression & operator=(const RegularExpression &rhs);
-
- //------------------------------------------------------------------
- /// Compile a regular expression.
- ///
- /// Compile a regular expression using the supplied regular
- /// expression text. The compiled regular expression lives
- /// in this object so that it can be readily used for regular
- /// expression matches. Execute() can be called after the regular
- /// expression is compiled. Any previously compiled regular
- /// expression contained in this object will be freed.
- ///
- /// @param[in] re
- /// A NULL terminated C string that represents the regular
- /// expression to compile.
- ///
- /// @return
- /// \b true if the regular expression compiles successfully,
- /// \b false otherwise.
- //------------------------------------------------------------------
- bool
- Compile (const char* re);
-
- //------------------------------------------------------------------
- /// Executes a regular expression.
- ///
- /// Execute a regular expression match using the compiled regular
- /// expression that is already in this object against the match
- /// string \a s. If any parens are used for regular expression
- /// matches \a match_count should indicate the number of regmatch_t
- /// values that are present in \a match_ptr.
- ///
- /// @param[in] string
- /// The string to match against the compile regular expression.
- ///
- /// @param[in] match
- /// A pointer to a RegularExpression::Match structure that was
- /// properly initialized with the desired number of maximum
- /// matches, or nullptr if no parenthesized matching is needed.
- ///
- /// @return
- /// \b true if \a string matches the compiled regular
- /// expression, \b false otherwise.
- //------------------------------------------------------------------
- bool
- Execute(const char* string, Match *match = nullptr) const;
-
- size_t
- GetErrorAsCString (char *err_str, size_t err_str_max_len) const;
-
- //------------------------------------------------------------------
- /// Free the compiled regular expression.
- ///
- /// If this object contains a valid compiled regular expression,
- /// this function will free any resources it was consuming.
- //------------------------------------------------------------------
- void
- Free ();
-
- //------------------------------------------------------------------
- /// Access the regular expression text.
- ///
- /// Returns the text that was used to compile the current regular
- /// expression.
- ///
- /// @return
- /// The NULL terminated C string that was used to compile the
- /// current regular expression
- //------------------------------------------------------------------
- const char*
- GetText () const;
-
- //------------------------------------------------------------------
- /// Test if valid.
- ///
- /// Test if this object contains a valid regular expression.
- ///
- /// @return
- /// \b true if the regular expression compiled and is ready
- /// for execution, \b false otherwise.
- //------------------------------------------------------------------
- bool
- IsValid () const;
-
- void
- Clear ()
- {
- Free();
- m_re.clear();
- m_comp_err = 1;
+ class Match {
+ public:
+ Match(uint32_t max_matches) : m_matches() {
+ if (max_matches > 0)
+ m_matches.resize(max_matches + 1);
+ }
+
+ void Clear() {
+ const size_t num_matches = m_matches.size();
+ regmatch_t invalid_match = {-1, -1};
+ for (size_t i = 0; i < num_matches; ++i)
+ m_matches[i] = invalid_match;
}
-
- int
- GetErrorCode() const
- {
- return m_comp_err;
+
+ size_t GetSize() const { return m_matches.size(); }
+
+ regmatch_t *GetData() {
+ return (m_matches.empty() ? nullptr : m_matches.data());
}
- bool
- operator < (const RegularExpression& rhs) const;
+ bool GetMatchAtIndex(const char *s, uint32_t idx,
+ std::string &match_str) const;
+
+ bool GetMatchAtIndex(const char *s, uint32_t idx,
+ llvm::StringRef &match_str) const;
+
+ bool GetMatchSpanningIndices(const char *s, uint32_t idx1, uint32_t idx2,
+ llvm::StringRef &match_str) const;
+
+ protected:
+ std::vector<regmatch_t>
+ m_matches; ///< Where parenthesized subexpressions results are stored
+ };
+
+ //------------------------------------------------------------------
+ /// Default constructor.
+ ///
+ /// The default constructor that initializes the object state such
+ /// that it contains no compiled regular expression.
+ //------------------------------------------------------------------
+ RegularExpression();
+
+ explicit RegularExpression(const char *re);
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ ///
+ /// Any previously compiled regular expression contained in this
+ /// object will be freed.
+ //------------------------------------------------------------------
+ ~RegularExpression();
+
+ RegularExpression(const RegularExpression &rhs);
+
+ const RegularExpression &operator=(const RegularExpression &rhs);
+
+ //------------------------------------------------------------------
+ /// Compile a regular expression.
+ ///
+ /// Compile a regular expression using the supplied regular
+ /// expression text. The compiled regular expression lives
+ /// in this object so that it can be readily used for regular
+ /// expression matches. Execute() can be called after the regular
+ /// expression is compiled. Any previously compiled regular
+ /// expression contained in this object will be freed.
+ ///
+ /// @param[in] re
+ /// A NULL terminated C string that represents the regular
+ /// expression to compile.
+ ///
+ /// @return
+ /// \b true if the regular expression compiles successfully,
+ /// \b false otherwise.
+ //------------------------------------------------------------------
+ bool Compile(const char *re);
+
+ //------------------------------------------------------------------
+ /// Executes a regular expression.
+ ///
+ /// Execute a regular expression match using the compiled regular
+ /// expression that is already in this object against the match
+ /// string \a s. If any parens are used for regular expression
+ /// matches \a match_count should indicate the number of regmatch_t
+ /// values that are present in \a match_ptr.
+ ///
+ /// @param[in] string
+ /// The string to match against the compile regular expression.
+ ///
+ /// @param[in] match
+ /// A pointer to a RegularExpression::Match structure that was
+ /// properly initialized with the desired number of maximum
+ /// matches, or nullptr if no parenthesized matching is needed.
+ ///
+ /// @return
+ /// \b true if \a string matches the compiled regular
+ /// expression, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Execute(const char *string, Match *match = nullptr) const;
+
+ size_t GetErrorAsCString(char *err_str, size_t err_str_max_len) const;
+
+ //------------------------------------------------------------------
+ /// Free the compiled regular expression.
+ ///
+ /// If this object contains a valid compiled regular expression,
+ /// this function will free any resources it was consuming.
+ //------------------------------------------------------------------
+ void Free();
+
+ //------------------------------------------------------------------
+ /// Access the regular expression text.
+ ///
+ /// Returns the text that was used to compile the current regular
+ /// expression.
+ ///
+ /// @return
+ /// The NULL terminated C string that was used to compile the
+ /// current regular expression
+ //------------------------------------------------------------------
+ const char *GetText() const;
+
+ //------------------------------------------------------------------
+ /// Test if valid.
+ ///
+ /// Test if this object contains a valid regular expression.
+ ///
+ /// @return
+ /// \b true if the regular expression compiled and is ready
+ /// for execution, \b false otherwise.
+ //------------------------------------------------------------------
+ bool IsValid() const;
+
+ void Clear() {
+ Free();
+ m_re.clear();
+ m_comp_err = 1;
+ }
+
+ int GetErrorCode() const { return m_comp_err; }
+
+ bool operator<(const RegularExpression &rhs) const;
private:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- std::string m_re; ///< A copy of the original regular expression text
- int m_comp_err; ///< Error code for the regular expression compilation
- regex_t m_preg; ///< The compiled regular expression
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ std::string m_re; ///< A copy of the original regular expression text
+ int m_comp_err; ///< Error code for the regular expression compilation
+ regex_t m_preg; ///< The compiled regular expression
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/STLUtils.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/STLUtils.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/STLUtils.h (original)
+++ lldb/trunk/include/lldb/Core/STLUtils.h Tue Sep 6 15:57:50 2016
@@ -24,61 +24,50 @@
//----------------------------------------------------------------------
// C string less than compare function object
//----------------------------------------------------------------------
-struct CStringCompareFunctionObject
-{
- bool operator() (const char* s1, const char* s2) const
- {
- return strcmp(s1, s2) < 0;
- }
+struct CStringCompareFunctionObject {
+ bool operator()(const char *s1, const char *s2) const {
+ return strcmp(s1, s2) < 0;
+ }
};
//----------------------------------------------------------------------
// C string equality function object (binary predicate).
//----------------------------------------------------------------------
-struct CStringEqualBinaryPredicate
-{
- bool operator()(const char* s1, const char* s2) const
- {
- return strcmp(s1, s2) == 0;
- }
+struct CStringEqualBinaryPredicate {
+ bool operator()(const char *s1, const char *s2) const {
+ return strcmp(s1, s2) == 0;
+ }
};
//----------------------------------------------------------------------
// Templated type for finding an entry in a std::map<F,S> whose value
// is equal to something
//----------------------------------------------------------------------
-template <class F, class S>
-class ValueEquals
-{
+template <class F, class S> class ValueEquals {
public:
- ValueEquals (const S& val) : second_value(val)
- {}
+ ValueEquals(const S &val) : second_value(val) {}
- // Compare the second item
- bool operator() (std::pair<const F, S> elem)
- {
- return elem.second == second_value;
- }
+ // Compare the second item
+ bool operator()(std::pair<const F, S> elem) {
+ return elem.second == second_value;
+ }
private:
- S second_value;
+ S second_value;
};
template <class T>
-inline void
-PrintAllCollectionElements(std::ostream &s,
- const T& coll,
- const char* header_cstr = nullptr,
- const char* separator_cstr = " ")
-{
- typename T::const_iterator pos;
-
- if (header_cstr)
- s << header_cstr;
- for (pos=coll.begin(); pos!=coll.end(); ++pos) {
- s << *pos << separator_cstr;
- }
- s << std::endl;
+inline void PrintAllCollectionElements(std::ostream &s, const T &coll,
+ const char *header_cstr = nullptr,
+ const char *separator_cstr = " ") {
+ typename T::const_iterator pos;
+
+ if (header_cstr)
+ s << header_cstr;
+ for (pos = coll.begin(); pos != coll.end(); ++pos) {
+ s << *pos << separator_cstr;
+ }
+ s << std::endl;
}
// The function object below can be used to delete a STL container that
@@ -86,10 +75,8 @@ PrintAllCollectionElements(std::ostream
//
// Usage: std::for_each(vector.begin(), vector.end(), for_each_delete());
-struct for_each_cplusplus_delete
-{
- template <typename T>
- void operator()(T *ptr){ delete ptr;}
+struct for_each_cplusplus_delete {
+ template <typename T> void operator()(T *ptr) { delete ptr; }
};
typedef std::vector<std::string> STLStringArray;
Modified: lldb/trunk/include/lldb/Core/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Scalar.h (original)
+++ lldb/trunk/include/lldb/Core/Scalar.h Tue Sep 6 15:57:50 2016
@@ -11,8 +11,8 @@
#define liblldb_Scalar_h_
#include "lldb/lldb-private.h"
-#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
#define NUM_OF_WORDS_INT128 2
#define BITWIDTH_INT128 128
@@ -27,343 +27,307 @@ namespace lldb_private {
// their types and values before performing these operations. Type
// promotion currently follows the ANSI C type promotion rules.
//----------------------------------------------------------------------
-class Scalar
-{
+class Scalar {
public:
- enum Type
- {
- e_void = 0,
- e_sint,
- e_uint,
- e_slong,
- e_ulong,
- e_slonglong,
- e_ulonglong,
- e_float,
- e_double,
- e_long_double,
- e_uint128,
- e_sint128,
- e_uint256,
- e_sint256
- };
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- Scalar();
- Scalar(int v) : m_type(e_sint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v, true);}
- Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) { m_integer = llvm::APInt(sizeof(int) * 8, v);}
- Scalar(long v) : m_type(e_slong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v, true);}
- Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long) * 8, v);}
- Scalar(long long v) : m_type(e_slonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v, true);}
- Scalar(unsigned long long v): m_type(e_ulonglong), m_float((float)0) { m_integer = llvm::APInt(sizeof(long long) * 8, v);}
- Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); }
- Scalar(double v) : m_type(e_double), m_float(v) { m_float = llvm::APFloat(v); }
- Scalar(long double v, bool ieee_quad)
- : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad)
- {
- if(ieee_quad)
- m_float = llvm::APFloat(llvm::APFloat::IEEEquad, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
- else
- m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended, llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
- }
- Scalar(llvm::APInt v) :
- m_type(),
- m_float((float)0)
- {
- m_integer = llvm::APInt(v);
- switch(m_integer.getBitWidth())
- {
- case 8:
- case 16:
- case 32:
- if(m_integer.isSignedIntN(sizeof(sint_t) * 8))
- m_type = e_sint;
- else
- m_type = e_uint;
- break;
- case 64:
- if(m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
- m_type = e_slonglong;
- else
- m_type = e_ulonglong;
- break;
- case 128:
- if(m_integer.isSignedIntN(BITWIDTH_INT128))
- m_type = e_sint128;
- else
- m_type = e_uint128;
- break;
- case 256:
- if(m_integer.isSignedIntN(BITWIDTH_INT256))
- m_type = e_sint256;
- else
- m_type = e_uint256;
- break;
- }
- }
- Scalar(const Scalar& rhs);
- //Scalar(const RegisterValue& reg_value);
- virtual ~Scalar();
-
- bool
- SignExtend (uint32_t bit_pos);
-
- bool
- ExtractBitfield (uint32_t bit_size,
- uint32_t bit_offset);
-
- bool
- SetBit(uint32_t bit);
-
- bool
- ClearBit(uint32_t bit);
-
- const void *
- GetBytes() const;
-
- size_t
- GetByteSize() const;
-
- bool
- GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
-
- size_t
- GetAsMemoryData (void *dst,
- size_t dst_len,
- lldb::ByteOrder dst_byte_order,
- Error &error) const;
-
- bool
- IsZero() const;
-
- void
- Clear() { m_type = e_void; m_integer.clearAllBits(); }
-
- const char *
- GetTypeAsCString() const;
-
- void
- GetValue (Stream *s, bool show_type) const;
-
- bool
- IsValid() const
- {
- return (m_type >= e_sint) && (m_type <= e_long_double);
+ enum Type {
+ e_void = 0,
+ e_sint,
+ e_uint,
+ e_slong,
+ e_ulong,
+ e_slonglong,
+ e_ulonglong,
+ e_float,
+ e_double,
+ e_long_double,
+ e_uint128,
+ e_sint128,
+ e_uint256,
+ e_sint256
+ };
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ Scalar();
+ Scalar(int v) : m_type(e_sint), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(int) * 8, v, true);
+ }
+ Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(int) * 8, v);
+ }
+ Scalar(long v) : m_type(e_slong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long) * 8, v, true);
+ }
+ Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long) * 8, v);
+ }
+ Scalar(long long v) : m_type(e_slonglong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long long) * 8, v, true);
+ }
+ Scalar(unsigned long long v) : m_type(e_ulonglong), m_float((float)0) {
+ m_integer = llvm::APInt(sizeof(long long) * 8, v);
+ }
+ Scalar(float v) : m_type(e_float), m_float(v) { m_float = llvm::APFloat(v); }
+ Scalar(double v) : m_type(e_double), m_float(v) {
+ m_float = llvm::APFloat(v);
+ }
+ Scalar(long double v, bool ieee_quad)
+ : m_type(e_long_double), m_float((float)0), m_ieee_quad(ieee_quad) {
+ if (ieee_quad)
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad,
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ ((type128 *)&v)->x));
+ else
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended,
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ ((type128 *)&v)->x));
+ }
+ Scalar(llvm::APInt v) : m_type(), m_float((float)0) {
+ m_integer = llvm::APInt(v);
+ switch (m_integer.getBitWidth()) {
+ case 8:
+ case 16:
+ case 32:
+ if (m_integer.isSignedIntN(sizeof(sint_t) * 8))
+ m_type = e_sint;
+ else
+ m_type = e_uint;
+ break;
+ case 64:
+ if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
+ m_type = e_slonglong;
+ else
+ m_type = e_ulonglong;
+ break;
+ case 128:
+ if (m_integer.isSignedIntN(BITWIDTH_INT128))
+ m_type = e_sint128;
+ else
+ m_type = e_uint128;
+ break;
+ case 256:
+ if (m_integer.isSignedIntN(BITWIDTH_INT256))
+ m_type = e_sint256;
+ else
+ m_type = e_uint256;
+ break;
}
+ }
+ Scalar(const Scalar &rhs);
+ // Scalar(const RegisterValue& reg_value);
+ virtual ~Scalar();
- bool
- Promote(Scalar::Type type);
+ bool SignExtend(uint32_t bit_pos);
- bool
- Cast (Scalar::Type type);
-
- bool
- MakeSigned ();
-
- bool
- MakeUnsigned ();
-
- static const char *
- GetValueTypeAsCString (Scalar::Type value_type);
-
- static Scalar::Type
- GetValueTypeForSignedIntegerWithByteSize (size_t byte_size);
-
- static Scalar::Type
- GetValueTypeForUnsignedIntegerWithByteSize (size_t byte_size);
-
- static Scalar::Type
- GetValueTypeForFloatWithByteSize (size_t byte_size);
-
- //----------------------------------------------------------------------
- // All operators can benefits from the implicit conversions that will
- // happen automagically by the compiler, so no temporary objects will
- // need to be created. As a result, we currently don't need a variety of
- // overloaded set value accessors.
- //----------------------------------------------------------------------
- Scalar& operator= (const int i);
- Scalar& operator= (unsigned int v);
- Scalar& operator= (long v);
- Scalar& operator= (unsigned long v);
- Scalar& operator= (long long v);
- Scalar& operator= (unsigned long long v);
- Scalar& operator= (float v);
- Scalar& operator= (double v);
- Scalar& operator= (long double v);
- Scalar& operator= (llvm::APInt v);
- Scalar& operator= (const Scalar& rhs); // Assignment operator
- Scalar& operator+= (const Scalar& rhs);
- Scalar& operator<<= (const Scalar& rhs); // Shift left
- Scalar& operator>>= (const Scalar& rhs); // Shift right (arithmetic)
- Scalar& operator&= (const Scalar& rhs);
-
- //----------------------------------------------------------------------
- // Shifts the current value to the right without maintaining the current
- // sign of the value (if it is signed).
- //----------------------------------------------------------------------
- bool
- ShiftRightLogical(const Scalar& rhs); // Returns true on success
-
- //----------------------------------------------------------------------
- // Takes the absolute value of the current value if it is signed, else
- // the value remains unchanged.
- // Returns false if the contained value has a void type.
- //----------------------------------------------------------------------
- bool
- AbsoluteValue(); // Returns true on success
- //----------------------------------------------------------------------
- // Negates the current value (even for unsigned values).
- // Returns false if the contained value has a void type.
- //----------------------------------------------------------------------
- bool
- UnaryNegate(); // Returns true on success
- //----------------------------------------------------------------------
- // Inverts all bits in the current value as long as it isn't void or
- // a float/double/long double type.
- // Returns false if the contained value has a void/float/double/long
- // double type, else the value is inverted and true is returned.
- //----------------------------------------------------------------------
- bool
- OnesComplement(); // Returns true on success
-
- //----------------------------------------------------------------------
- // Access the type of the current value.
- //----------------------------------------------------------------------
- Scalar::Type
- GetType() const { return m_type; }
-
- //----------------------------------------------------------------------
- // Returns a casted value of the current contained data without
- // modifying the current value. FAIL_VALUE will be returned if the type
- // of the value is void or invalid.
- //----------------------------------------------------------------------
- int
- SInt(int fail_value = 0) const;
-
- unsigned char
- UChar(unsigned char fail_value = 0) const;
-
- signed char
- SChar(char fail_value = 0) const;
-
- unsigned short
- UShort(unsigned short fail_value = 0) const;
-
- short
- SShort(short fail_value = 0) const;
-
- unsigned int
- UInt(unsigned int fail_value = 0) const;
-
- long
- SLong(long fail_value = 0) const;
-
- unsigned long
- ULong(unsigned long fail_value = 0) const;
-
- long long
- SLongLong(long long fail_value = 0) const;
-
- unsigned long long
- ULongLong(unsigned long long fail_value = 0) const;
-
- llvm::APInt
- SInt128(llvm::APInt& fail_value) const;
-
- llvm::APInt
- UInt128(const llvm::APInt& fail_value) const;
-
- llvm::APInt
- SInt256(llvm::APInt& fail_value) const;
-
- llvm::APInt
- UInt256(const llvm::APInt& fail_value) const;
-
- float
- Float(float fail_value = 0.0f) const;
-
- double
- Double(double fail_value = 0.0) const;
-
- long double
- LongDouble(long double fail_value = 0.0) const;
-
- Error
- SetValueFromCString (const char *s, lldb::Encoding encoding, size_t byte_size);
-
- Error
- SetValueFromData (DataExtractor &data, lldb::Encoding encoding, size_t byte_size);
-
- static bool
- UIntValueIsValidForSize (uint64_t uval64, size_t total_byte_size)
- {
- if (total_byte_size > 8)
- return false;
+ bool ExtractBitfield(uint32_t bit_size, uint32_t bit_offset);
- if (total_byte_size == 8)
- return true;
+ bool SetBit(uint32_t bit);
- const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
- return uval64 <= max;
- }
+ bool ClearBit(uint32_t bit);
- static bool
- SIntValueIsValidForSize (int64_t sval64, size_t total_byte_size)
- {
- if (total_byte_size > 8)
- return false;
-
- if (total_byte_size == 8)
- return true;
-
- const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
- const int64_t min = ~(max);
- return min <= sval64 && sval64 <= max;
- }
+ const void *GetBytes() const;
+
+ size_t GetByteSize() const;
+
+ bool GetData(DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const;
+
+ size_t GetAsMemoryData(void *dst, size_t dst_len,
+ lldb::ByteOrder dst_byte_order, Error &error) const;
+
+ bool IsZero() const;
+
+ void Clear() {
+ m_type = e_void;
+ m_integer.clearAllBits();
+ }
+
+ const char *GetTypeAsCString() const;
+
+ void GetValue(Stream *s, bool show_type) const;
+
+ bool IsValid() const {
+ return (m_type >= e_sint) && (m_type <= e_long_double);
+ }
+
+ bool Promote(Scalar::Type type);
+
+ bool Cast(Scalar::Type type);
+
+ bool MakeSigned();
+
+ bool MakeUnsigned();
+
+ static const char *GetValueTypeAsCString(Scalar::Type value_type);
+
+ static Scalar::Type
+ GetValueTypeForSignedIntegerWithByteSize(size_t byte_size);
+
+ static Scalar::Type
+ GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size);
+
+ static Scalar::Type GetValueTypeForFloatWithByteSize(size_t byte_size);
+
+ //----------------------------------------------------------------------
+ // All operators can benefits from the implicit conversions that will
+ // happen automagically by the compiler, so no temporary objects will
+ // need to be created. As a result, we currently don't need a variety of
+ // overloaded set value accessors.
+ //----------------------------------------------------------------------
+ Scalar &operator=(const int i);
+ Scalar &operator=(unsigned int v);
+ Scalar &operator=(long v);
+ Scalar &operator=(unsigned long v);
+ Scalar &operator=(long long v);
+ Scalar &operator=(unsigned long long v);
+ Scalar &operator=(float v);
+ Scalar &operator=(double v);
+ Scalar &operator=(long double v);
+ Scalar &operator=(llvm::APInt v);
+ Scalar &operator=(const Scalar &rhs); // Assignment operator
+ Scalar &operator+=(const Scalar &rhs);
+ Scalar &operator<<=(const Scalar &rhs); // Shift left
+ Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic)
+ Scalar &operator&=(const Scalar &rhs);
+
+ //----------------------------------------------------------------------
+ // Shifts the current value to the right without maintaining the current
+ // sign of the value (if it is signed).
+ //----------------------------------------------------------------------
+ bool ShiftRightLogical(const Scalar &rhs); // Returns true on success
+
+ //----------------------------------------------------------------------
+ // Takes the absolute value of the current value if it is signed, else
+ // the value remains unchanged.
+ // Returns false if the contained value has a void type.
+ //----------------------------------------------------------------------
+ bool AbsoluteValue(); // Returns true on success
+ //----------------------------------------------------------------------
+ // Negates the current value (even for unsigned values).
+ // Returns false if the contained value has a void type.
+ //----------------------------------------------------------------------
+ bool UnaryNegate(); // Returns true on success
+ //----------------------------------------------------------------------
+ // Inverts all bits in the current value as long as it isn't void or
+ // a float/double/long double type.
+ // Returns false if the contained value has a void/float/double/long
+ // double type, else the value is inverted and true is returned.
+ //----------------------------------------------------------------------
+ bool OnesComplement(); // Returns true on success
+
+ //----------------------------------------------------------------------
+ // Access the type of the current value.
+ //----------------------------------------------------------------------
+ Scalar::Type GetType() const { return m_type; }
+
+ //----------------------------------------------------------------------
+ // Returns a casted value of the current contained data without
+ // modifying the current value. FAIL_VALUE will be returned if the type
+ // of the value is void or invalid.
+ //----------------------------------------------------------------------
+ int SInt(int fail_value = 0) const;
+
+ unsigned char UChar(unsigned char fail_value = 0) const;
+
+ signed char SChar(char fail_value = 0) const;
+
+ unsigned short UShort(unsigned short fail_value = 0) const;
+
+ short SShort(short fail_value = 0) const;
+
+ unsigned int UInt(unsigned int fail_value = 0) const;
+
+ long SLong(long fail_value = 0) const;
+
+ unsigned long ULong(unsigned long fail_value = 0) const;
+
+ long long SLongLong(long long fail_value = 0) const;
+
+ unsigned long long ULongLong(unsigned long long fail_value = 0) const;
+
+ llvm::APInt SInt128(llvm::APInt &fail_value) const;
+
+ llvm::APInt UInt128(const llvm::APInt &fail_value) const;
+
+ llvm::APInt SInt256(llvm::APInt &fail_value) const;
+
+ llvm::APInt UInt256(const llvm::APInt &fail_value) const;
+
+ float Float(float fail_value = 0.0f) const;
+
+ double Double(double fail_value = 0.0) const;
+
+ long double LongDouble(long double fail_value = 0.0) const;
+
+ Error SetValueFromCString(const char *s, lldb::Encoding encoding,
+ size_t byte_size);
+
+ Error SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
+ size_t byte_size);
+
+ static bool UIntValueIsValidForSize(uint64_t uval64, size_t total_byte_size) {
+ if (total_byte_size > 8)
+ return false;
+
+ if (total_byte_size == 8)
+ return true;
+
+ const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
+ return uval64 <= max;
+ }
+
+ static bool SIntValueIsValidForSize(int64_t sval64, size_t total_byte_size) {
+ if (total_byte_size > 8)
+ return false;
+
+ if (total_byte_size == 8)
+ return true;
+
+ const int64_t max = ((int64_t)1 << (uint64_t)(total_byte_size * 8 - 1)) - 1;
+ const int64_t min = ~(max);
+ return min <= sval64 && sval64 <= max;
+ }
protected:
- typedef char schar_t;
- typedef unsigned char uchar_t;
- typedef short sshort_t;
- typedef unsigned short ushort_t;
- typedef int sint_t;
- typedef unsigned int uint_t;
- typedef long slong_t;
- typedef unsigned long ulong_t;
- typedef long long slonglong_t;
- typedef unsigned long long ulonglong_t;
- typedef float float_t;
- typedef double double_t;
- typedef long double long_double_t;
-
- //------------------------------------------------------------------
- // Classes that inherit from Scalar can see and modify these
- //------------------------------------------------------------------
- Scalar::Type m_type;
- llvm::APInt m_integer;
- llvm::APFloat m_float;
- bool m_ieee_quad = false;
+ typedef char schar_t;
+ typedef unsigned char uchar_t;
+ typedef short sshort_t;
+ typedef unsigned short ushort_t;
+ typedef int sint_t;
+ typedef unsigned int uint_t;
+ typedef long slong_t;
+ typedef unsigned long ulong_t;
+ typedef long long slonglong_t;
+ typedef unsigned long long ulonglong_t;
+ typedef float float_t;
+ typedef double double_t;
+ typedef long double long_double_t;
+
+ //------------------------------------------------------------------
+ // Classes that inherit from Scalar can see and modify these
+ //------------------------------------------------------------------
+ Scalar::Type m_type;
+ llvm::APInt m_integer;
+ llvm::APFloat m_float;
+ bool m_ieee_quad = false;
private:
- friend const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator- (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator/ (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator* (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator& (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator| (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator% (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator^ (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator<< (const Scalar& lhs, const Scalar& rhs);
- friend const Scalar operator>> (const Scalar& lhs, const Scalar& rhs);
- friend bool operator== (const Scalar& lhs, const Scalar& rhs);
- friend bool operator!= (const Scalar& lhs, const Scalar& rhs);
- friend bool operator< (const Scalar& lhs, const Scalar& rhs);
- friend bool operator<= (const Scalar& lhs, const Scalar& rhs);
- friend bool operator> (const Scalar& lhs, const Scalar& rhs);
- friend bool operator>= (const Scalar& lhs, const Scalar& rhs);
-
+ friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator-(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator/(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator*(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator&(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator|(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator%(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator^(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator<<(const Scalar &lhs, const Scalar &rhs);
+ friend const Scalar operator>>(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator==(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator!=(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator<(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator<=(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator>(const Scalar &lhs, const Scalar &rhs);
+ friend bool operator>=(const Scalar &lhs, const Scalar &rhs);
};
//----------------------------------------------------------------------
@@ -381,23 +345,23 @@ private:
// Differentiate among members functions, non-member functions, and
// friend functions
//----------------------------------------------------------------------
-const Scalar operator+ (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator- (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator/ (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator* (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator& (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator| (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator% (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator^ (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator<< (const Scalar& lhs, const Scalar& rhs);
-const Scalar operator>> (const Scalar& lhs, const Scalar& rhs);
-bool operator== (const Scalar& lhs, const Scalar& rhs);
-bool operator!= (const Scalar& lhs, const Scalar& rhs);
-bool operator< (const Scalar& lhs, const Scalar& rhs);
-bool operator<= (const Scalar& lhs, const Scalar& rhs);
-bool operator> (const Scalar& lhs, const Scalar& rhs);
-bool operator>= (const Scalar& lhs, const Scalar& rhs);
+const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator-(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator/(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator*(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator&(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator|(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator%(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator^(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator<<(const Scalar &lhs, const Scalar &rhs);
+const Scalar operator>>(const Scalar &lhs, const Scalar &rhs);
+bool operator==(const Scalar &lhs, const Scalar &rhs);
+bool operator!=(const Scalar &lhs, const Scalar &rhs);
+bool operator<(const Scalar &lhs, const Scalar &rhs);
+bool operator<=(const Scalar &lhs, const Scalar &rhs);
+bool operator>(const Scalar &lhs, const Scalar &rhs);
+bool operator>=(const Scalar &lhs, const Scalar &rhs);
} // namespace lldb_private
-#endif // liblldb_Scalar_h_
+#endif // liblldb_Scalar_h_
Modified: lldb/trunk/include/lldb/Core/SearchFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SearchFilter.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SearchFilter.h (original)
+++ lldb/trunk/include/lldb/Core/SearchFilter.h Tue Sep 6 15:57:50 2016
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/FileSpecList.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -30,45 +30,40 @@ namespace lldb_private {
/// Provides the callback and search depth for the SearchFilter search.
//----------------------------------------------------------------------
-class Searcher
-{
+class Searcher {
public:
- typedef enum {
- eCallbackReturnStop = 0, // Stop the iteration
- eCallbackReturnContinue, // Continue the iteration
- eCallbackReturnPop // Pop one level up and continue iterating
- } CallbackReturn;
-
- typedef enum {
- eDepthTarget,
- eDepthModule,
- eDepthCompUnit,
- eDepthFunction,
- eDepthBlock,
- eDepthAddress
- } Depth;
-
- Searcher ();
-
- virtual ~Searcher ();
-
- virtual CallbackReturn
- SearchCallback (SearchFilter &filter,
- SymbolContext &context,
- Address *addr,
- bool complete) = 0;
-
- virtual Depth
- GetDepth () = 0;
-
- //------------------------------------------------------------------
- /// Prints a canonical description for the searcher to the stream \a s.
- ///
- /// @param[in] s
- /// Stream to which the output is copied.
- //------------------------------------------------------------------
- virtual void
- GetDescription(Stream *s);
+ typedef enum {
+ eCallbackReturnStop = 0, // Stop the iteration
+ eCallbackReturnContinue, // Continue the iteration
+ eCallbackReturnPop // Pop one level up and continue iterating
+ } CallbackReturn;
+
+ typedef enum {
+ eDepthTarget,
+ eDepthModule,
+ eDepthCompUnit,
+ eDepthFunction,
+ eDepthBlock,
+ eDepthAddress
+ } Depth;
+
+ Searcher();
+
+ virtual ~Searcher();
+
+ virtual CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context, Address *addr,
+ bool complete) = 0;
+
+ virtual Depth GetDepth() = 0;
+
+ //------------------------------------------------------------------
+ /// Prints a canonical description for the searcher to the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream to which the output is copied.
+ //------------------------------------------------------------------
+ virtual void GetDescription(Stream *s);
};
//----------------------------------------------------------------------
@@ -82,206 +77,188 @@ public:
/// General Outline:
/// Provides the callback and search depth for the SearchFilter search.
///
-/// The search is done by cooperation between the search filter and the searcher.
+/// The search is done by cooperation between the search filter and the
+/// searcher.
/// The search filter does the heavy work of recursing through the SymbolContext
-/// space of the target program's symbol space. The Searcher specifies the depth
-/// at which it wants its callback to be invoked. Note that since the resolution
+/// space of the target program's symbol space. The Searcher specifies the
+/// depth
+/// at which it wants its callback to be invoked. Note that since the
+/// resolution
/// of the Searcher may be greater than that of the SearchFilter, before the
/// Searcher qualifies an address it should pass it to "AddressPasses."
/// The default implementation is "Everything Passes."
//----------------------------------------------------------------------
-class SearchFilter
-{
+class SearchFilter {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- //------------------------------------------------------------------
- SearchFilter (const lldb::TargetSP &target_sp);
-
- SearchFilter (const SearchFilter& rhs);
-
- virtual
- ~SearchFilter ();
-
- SearchFilter&
- operator=(const SearchFilter& rhs);
-
- //------------------------------------------------------------------
- /// Call this method with a file spec to see if that spec passes the filter.
- ///
- /// @param[in] spec
- /// The file spec to check against the filter.
- /// @return
- /// \b true if \a spec passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ModulePasses (const FileSpec &spec);
-
- //------------------------------------------------------------------
- /// Call this method with a Module to see if that module passes the filter.
- ///
- /// @param[in] module
- /// The Module to check against the filter.
- ///
- /// @return
- /// \b true if \a module passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- ModulePasses (const lldb::ModuleSP &module_sp);
-
- //------------------------------------------------------------------
- /// Call this method with a Address to see if \a address passes the filter.
- ///
- /// @param[in] addr
- /// The address to check against the filter.
- ///
- /// @return
- /// \b true if \a address passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- AddressPasses (Address &addr);
-
- //------------------------------------------------------------------
- /// Call this method with a FileSpec to see if \a file spec passes the filter
- /// as the name of a compilation unit.
- ///
- /// @param[in] fileSpec
- /// The file spec to check against the filter.
- ///
- /// @return
- /// \b true if \a file spec passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- CompUnitPasses (FileSpec &fileSpec);
-
- //------------------------------------------------------------------
- /// Call this method with a CompileUnit to see if \a comp unit passes the filter.
- ///
- /// @param[in] compUnit
- /// The CompileUnit to check against the filter.
- ///
- /// @return
- /// \b true if \a Comp Unit passes, and \b false otherwise.
- //------------------------------------------------------------------
- virtual bool
- CompUnitPasses (CompileUnit &compUnit);
-
- //------------------------------------------------------------------
- /// Call this method to do the search using the Searcher.
- ///
- /// @param[in] searcher
- /// The searcher to drive with this search.
- ///
- //------------------------------------------------------------------
- virtual void
- Search (Searcher &searcher);
-
- //------------------------------------------------------------------
- /// Call this method to do the search using the Searcher in the module list
- /// \a modules.
- ///
- /// @param[in] searcher
- /// The searcher to drive with this search.
- ///
- /// @param[in] modules
- /// The module list within which to restrict the search.
- ///
- //------------------------------------------------------------------
- virtual void
- SearchInModuleList (Searcher &searcher, ModuleList &modules);
-
- //------------------------------------------------------------------
- /// This determines which items are REQUIRED for the filter to pass.
- /// For instance, if you are filtering by Compilation Unit, obviously
- /// symbols that have no compilation unit can't pass So return eSymbolContextCU
- /// and search callbacks can then short cut the search to avoid looking at
- /// things that obviously won't pass.
- ///
- /// @return
- /// The required elements for the search, which is an or'ed together
- /// set of lldb:SearchContextItem enum's.
- ///
- //------------------------------------------------------------------
- virtual uint32_t
- GetFilterRequiredItems ();
-
- //------------------------------------------------------------------
- /// Prints a canonical description for the search filter to the stream \a s.
- ///
- /// @param[in] s
- /// Stream to which the output is copied.
- //------------------------------------------------------------------
- virtual void
- GetDescription(Stream *s);
-
- //------------------------------------------------------------------
- /// Standard "Dump" method. At present it does nothing.
- //------------------------------------------------------------------
- virtual void
- Dump (Stream *s) const;
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ //------------------------------------------------------------------
+ SearchFilter(const lldb::TargetSP &target_sp);
+
+ SearchFilter(const SearchFilter &rhs);
+
+ virtual ~SearchFilter();
+
+ SearchFilter &operator=(const SearchFilter &rhs);
+
+ //------------------------------------------------------------------
+ /// Call this method with a file spec to see if that spec passes the filter.
+ ///
+ /// @param[in] spec
+ /// The file spec to check against the filter.
+ /// @return
+ /// \b true if \a spec passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ModulePasses(const FileSpec &spec);
+
+ //------------------------------------------------------------------
+ /// Call this method with a Module to see if that module passes the filter.
+ ///
+ /// @param[in] module
+ /// The Module to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a module passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
+
+ //------------------------------------------------------------------
+ /// Call this method with a Address to see if \a address passes the filter.
+ ///
+ /// @param[in] addr
+ /// The address to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a address passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool AddressPasses(Address &addr);
+
+ //------------------------------------------------------------------
+ /// Call this method with a FileSpec to see if \a file spec passes the filter
+ /// as the name of a compilation unit.
+ ///
+ /// @param[in] fileSpec
+ /// The file spec to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a file spec passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool CompUnitPasses(FileSpec &fileSpec);
+
+ //------------------------------------------------------------------
+ /// Call this method with a CompileUnit to see if \a comp unit passes the
+ /// filter.
+ ///
+ /// @param[in] compUnit
+ /// The CompileUnit to check against the filter.
+ ///
+ /// @return
+ /// \b true if \a Comp Unit passes, and \b false otherwise.
+ //------------------------------------------------------------------
+ virtual bool CompUnitPasses(CompileUnit &compUnit);
+
+ //------------------------------------------------------------------
+ /// Call this method to do the search using the Searcher.
+ ///
+ /// @param[in] searcher
+ /// The searcher to drive with this search.
+ ///
+ //------------------------------------------------------------------
+ virtual void Search(Searcher &searcher);
+
+ //------------------------------------------------------------------
+ /// Call this method to do the search using the Searcher in the module list
+ /// \a modules.
+ ///
+ /// @param[in] searcher
+ /// The searcher to drive with this search.
+ ///
+ /// @param[in] modules
+ /// The module list within which to restrict the search.
+ ///
+ //------------------------------------------------------------------
+ virtual void SearchInModuleList(Searcher &searcher, ModuleList &modules);
+
+ //------------------------------------------------------------------
+ /// This determines which items are REQUIRED for the filter to pass.
+ /// For instance, if you are filtering by Compilation Unit, obviously
+ /// symbols that have no compilation unit can't pass So return
+ /// eSymbolContextCU
+ /// and search callbacks can then short cut the search to avoid looking at
+ /// things that obviously won't pass.
+ ///
+ /// @return
+ /// The required elements for the search, which is an or'ed together
+ /// set of lldb:SearchContextItem enum's.
+ ///
+ //------------------------------------------------------------------
+ virtual uint32_t GetFilterRequiredItems();
+
+ //------------------------------------------------------------------
+ /// Prints a canonical description for the search filter to the stream \a s.
+ ///
+ /// @param[in] s
+ /// Stream to which the output is copied.
+ //------------------------------------------------------------------
+ virtual void GetDescription(Stream *s);
+
+ //------------------------------------------------------------------
+ /// Standard "Dump" method. At present it does nothing.
+ //------------------------------------------------------------------
+ virtual void Dump(Stream *s) const;
- lldb::SearchFilterSP
- CopyForBreakpoint (Breakpoint &breakpoint);
+ lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint);
protected:
- // These are utility functions to assist with the search iteration. They are used by the
- // default Search method.
+ // These are utility functions to assist with the search iteration. They are
+ // used by the
+ // default Search method.
+
+ Searcher::CallbackReturn DoModuleIteration(const SymbolContext &context,
+ Searcher &searcher);
+
+ Searcher::CallbackReturn DoModuleIteration(const lldb::ModuleSP &module_sp,
+ Searcher &searcher);
- Searcher::CallbackReturn
- DoModuleIteration (const SymbolContext &context,
- Searcher &searcher);
-
- Searcher::CallbackReturn
- DoModuleIteration (const lldb::ModuleSP& module_sp,
- Searcher &searcher);
-
- Searcher::CallbackReturn
- DoCUIteration (const lldb::ModuleSP& module_sp,
- const SymbolContext &context,
- Searcher &searcher);
-
- Searcher::CallbackReturn
- DoFunctionIteration (Function *function,
- const SymbolContext &context,
- Searcher &searcher);
-
- virtual lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) = 0;
-
- void
- SetTarget(lldb::TargetSP &target_sp)
- {
- m_target_sp = target_sp;
- }
+ Searcher::CallbackReturn DoCUIteration(const lldb::ModuleSP &module_sp,
+ const SymbolContext &context,
+ Searcher &searcher);
- lldb::TargetSP m_target_sp; // Every filter has to be associated with a target for
- // now since you need a starting place for the search.
+ Searcher::CallbackReturn DoFunctionIteration(Function *function,
+ const SymbolContext &context,
+ Searcher &searcher);
+
+ virtual lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) = 0;
+
+ void SetTarget(lldb::TargetSP &target_sp) { m_target_sp = target_sp; }
+
+ lldb::TargetSP
+ m_target_sp; // Every filter has to be associated with a target for
+ // now since you need a starting place for the search.
};
//----------------------------------------------------------------------
-/// @class SearchFilterForUnconstrainedSearches SearchFilter.h "lldb/Core/SearchFilter.h"
-/// @brief This is a SearchFilter that searches through all modules. It also consults the Target::ModuleIsExcludedForUnconstrainedSearches.
+/// @class SearchFilterForUnconstrainedSearches SearchFilter.h
+/// "lldb/Core/SearchFilter.h"
+/// @brief This is a SearchFilter that searches through all modules. It also
+/// consults the Target::ModuleIsExcludedForUnconstrainedSearches.
//----------------------------------------------------------------------
-class SearchFilterForUnconstrainedSearches :
- public SearchFilter
-{
+class SearchFilterForUnconstrainedSearches : public SearchFilter {
public:
- SearchFilterForUnconstrainedSearches (const lldb::TargetSP &target_sp) : SearchFilter(target_sp) {}
- ~SearchFilterForUnconstrainedSearches() override = default;
-
- bool
- ModulePasses (const FileSpec &module_spec) override;
-
- bool
- ModulePasses (const lldb::ModuleSP &module_sp) override;
+ SearchFilterForUnconstrainedSearches(const lldb::TargetSP &target_sp)
+ : SearchFilter(target_sp) {}
+ ~SearchFilterForUnconstrainedSearches() override = default;
+
+ bool ModulePasses(const FileSpec &module_spec) override;
+
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
};
//----------------------------------------------------------------------
@@ -289,176 +266,139 @@ protected:
/// @brief This is a SearchFilter that restricts the search to a given module.
//----------------------------------------------------------------------
-class SearchFilterByModule :
- public SearchFilter
-{
+class SearchFilterByModule : public SearchFilter {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search,
- /// and the module to restrict the search to.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- ///
- /// @param[in] module
- /// The Module that limits the search.
- //------------------------------------------------------------------
- SearchFilterByModule (const lldb::TargetSP &targetSP,
- const FileSpec &module);
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search,
+ /// and the module to restrict the search to.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ ///
+ /// @param[in] module
+ /// The Module that limits the search.
+ //------------------------------------------------------------------
+ SearchFilterByModule(const lldb::TargetSP &targetSP, const FileSpec &module);
- SearchFilterByModule (const SearchFilterByModule& rhs);
+ SearchFilterByModule(const SearchFilterByModule &rhs);
- ~SearchFilterByModule() override;
+ ~SearchFilterByModule() override;
- SearchFilterByModule&
- operator=(const SearchFilterByModule& rhs);
+ SearchFilterByModule &operator=(const SearchFilterByModule &rhs);
- bool
- ModulePasses (const lldb::ModuleSP &module_sp) override;
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
- bool
- ModulePasses (const FileSpec &spec) override;
+ bool ModulePasses(const FileSpec &spec) override;
- bool
- AddressPasses (Address &address) override;
+ bool AddressPasses(Address &address) override;
- bool
- CompUnitPasses (FileSpec &fileSpec) override;
+ bool CompUnitPasses(FileSpec &fileSpec) override;
- bool
- CompUnitPasses (CompileUnit &compUnit) override;
+ bool CompUnitPasses(CompileUnit &compUnit) override;
- void
- GetDescription(Stream *s) override;
+ void GetDescription(Stream *s) override;
- uint32_t
- GetFilterRequiredItems () override;
+ uint32_t GetFilterRequiredItems() override;
- void
- Dump (Stream *s) const override;
+ void Dump(Stream *s) const override;
- void
- Search (Searcher &searcher) override;
+ void Search(Searcher &searcher) override;
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
private:
- FileSpec m_module_spec;
+ FileSpec m_module_spec;
};
-class SearchFilterByModuleList :
- public SearchFilter
-{
+class SearchFilterByModuleList : public SearchFilter {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search,
- /// and the module list to restrict the search to.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- ///
- /// @param[in] module
- /// The Module that limits the search.
- //------------------------------------------------------------------
- SearchFilterByModuleList (const lldb::TargetSP &targetSP,
- const FileSpecList &module_list);
-
- SearchFilterByModuleList (const SearchFilterByModuleList& rhs);
-
- ~SearchFilterByModuleList() override;
-
- SearchFilterByModuleList&
- operator=(const SearchFilterByModuleList& rhs);
-
- bool
- ModulePasses (const lldb::ModuleSP &module_sp) override;
-
- bool
- ModulePasses (const FileSpec &spec) override;
-
- bool
- AddressPasses (Address &address) override;
-
- bool
- CompUnitPasses (FileSpec &fileSpec) override;
-
- bool
- CompUnitPasses (CompileUnit &compUnit) override;
-
- void
- GetDescription(Stream *s) override;
-
- uint32_t
- GetFilterRequiredItems () override;
-
- void
- Dump (Stream *s) const override;
-
- void
- Search (Searcher &searcher) override;
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search,
+ /// and the module list to restrict the search to.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ ///
+ /// @param[in] module
+ /// The Module that limits the search.
+ //------------------------------------------------------------------
+ SearchFilterByModuleList(const lldb::TargetSP &targetSP,
+ const FileSpecList &module_list);
+
+ SearchFilterByModuleList(const SearchFilterByModuleList &rhs);
+
+ ~SearchFilterByModuleList() override;
+
+ SearchFilterByModuleList &operator=(const SearchFilterByModuleList &rhs);
+
+ bool ModulePasses(const lldb::ModuleSP &module_sp) override;
+
+ bool ModulePasses(const FileSpec &spec) override;
+
+ bool AddressPasses(Address &address) override;
+
+ bool CompUnitPasses(FileSpec &fileSpec) override;
+
+ bool CompUnitPasses(CompileUnit &compUnit) override;
+
+ void GetDescription(Stream *s) override;
+
+ uint32_t GetFilterRequiredItems() override;
+
+ void Dump(Stream *s) const override;
+
+ void Search(Searcher &searcher) override;
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
protected:
- FileSpecList m_module_spec_list;
+ FileSpecList m_module_spec_list;
};
-class SearchFilterByModuleListAndCU :
- public SearchFilterByModuleList
-{
+class SearchFilterByModuleListAndCU : public SearchFilterByModuleList {
public:
- //------------------------------------------------------------------
- /// The basic constructor takes a Target, which gives the space to search,
- /// and the module list to restrict the search to.
- ///
- /// @param[in] target
- /// The Target that provides the module list to search.
- ///
- /// @param[in] module
- /// The Module that limits the search.
- //------------------------------------------------------------------
- SearchFilterByModuleListAndCU (const lldb::TargetSP &targetSP,
- const FileSpecList &module_list,
- const FileSpecList &cu_list);
-
- SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs);
-
- ~SearchFilterByModuleListAndCU() override;
-
- SearchFilterByModuleListAndCU&
- operator=(const SearchFilterByModuleListAndCU& rhs);
-
- bool
- AddressPasses (Address &address) override;
-
- bool
- CompUnitPasses (FileSpec &fileSpec) override;
-
- bool
- CompUnitPasses (CompileUnit &compUnit) override;
-
- void
- GetDescription(Stream *s) override;
-
- uint32_t
- GetFilterRequiredItems () override;
-
- void
- Dump (Stream *s) const override;
-
- void
- Search (Searcher &searcher) override;
-
+ //------------------------------------------------------------------
+ /// The basic constructor takes a Target, which gives the space to search,
+ /// and the module list to restrict the search to.
+ ///
+ /// @param[in] target
+ /// The Target that provides the module list to search.
+ ///
+ /// @param[in] module
+ /// The Module that limits the search.
+ //------------------------------------------------------------------
+ SearchFilterByModuleListAndCU(const lldb::TargetSP &targetSP,
+ const FileSpecList &module_list,
+ const FileSpecList &cu_list);
+
+ SearchFilterByModuleListAndCU(const SearchFilterByModuleListAndCU &rhs);
+
+ ~SearchFilterByModuleListAndCU() override;
+
+ SearchFilterByModuleListAndCU &
+ operator=(const SearchFilterByModuleListAndCU &rhs);
+
+ bool AddressPasses(Address &address) override;
+
+ bool CompUnitPasses(FileSpec &fileSpec) override;
+
+ bool CompUnitPasses(CompileUnit &compUnit) override;
+
+ void GetDescription(Stream *s) override;
+
+ uint32_t GetFilterRequiredItems() override;
+
+ void Dump(Stream *s) const override;
+
+ void Search(Searcher &searcher) override;
+
protected:
- lldb::SearchFilterSP
- DoCopyForBreakpoint (Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
private:
- FileSpecList m_cu_spec_list;
+ FileSpecList m_cu_spec_list;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Tue Sep 6 15:57:50 2016
@@ -10,380 +10,254 @@
#ifndef liblldb_Section_h_
#define liblldb_Section_h_
-#include "lldb/lldb-private.h"
#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/ModuleChild.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/VMRange.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/lldb-private.h"
#include <limits.h>
namespace lldb_private {
-class SectionList
-{
+class SectionList {
public:
- typedef std::vector<lldb::SectionSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ typedef std::vector<lldb::SectionSP> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
+
+ SectionList();
- SectionList();
+ ~SectionList();
- ~SectionList();
+ SectionList &operator=(const SectionList &rhs);
- SectionList &
- operator =(const SectionList& rhs);
+ size_t AddSection(const lldb::SectionSP §ion_sp);
- size_t
- AddSection (const lldb::SectionSP& section_sp);
+ size_t AddUniqueSection(const lldb::SectionSP §ion_sp);
- size_t
- AddUniqueSection (const lldb::SectionSP& section_sp);
+ size_t FindSectionIndex(const Section *sect);
- size_t
- FindSectionIndex (const Section* sect);
+ bool ContainsSection(lldb::user_id_t sect_id) const;
- bool
- ContainsSection(lldb::user_id_t sect_id) const;
+ void Dump(Stream *s, Target *target, bool show_header, uint32_t depth) const;
- void
- Dump (Stream *s, Target *target, bool show_header, uint32_t depth) const;
+ lldb::SectionSP FindSectionByName(const ConstString §ion_dstr) const;
- lldb::SectionSP
- FindSectionByName (const ConstString §ion_dstr) const;
+ lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const;
- lldb::SectionSP
- FindSectionByID (lldb::user_id_t sect_id) const;
+ lldb::SectionSP FindSectionByType(lldb::SectionType sect_type,
+ bool check_children,
+ size_t start_idx = 0) const;
- lldb::SectionSP
- FindSectionByType (lldb::SectionType sect_type, bool check_children, size_t start_idx = 0) const;
+ lldb::SectionSP
+ FindSectionContainingFileAddress(lldb::addr_t addr,
+ uint32_t depth = UINT32_MAX) const;
- lldb::SectionSP
- FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const;
+ // Get the number of sections in this list only
+ size_t GetSize() const { return m_sections.size(); }
- // Get the number of sections in this list only
- size_t
- GetSize () const
- {
- return m_sections.size();
- }
+ // Get the number of sections in this list, and any contained child sections
+ size_t GetNumSections(uint32_t depth) const;
- // Get the number of sections in this list, and any contained child sections
- size_t
- GetNumSections (uint32_t depth) const;
+ bool ReplaceSection(lldb::user_id_t sect_id,
+ const lldb::SectionSP §ion_sp,
+ uint32_t depth = UINT32_MAX);
- bool
- ReplaceSection (lldb::user_id_t sect_id, const lldb::SectionSP& section_sp, uint32_t depth = UINT32_MAX);
+ // Warning, this can be slow as it's removing items from a std::vector.
+ bool DeleteSection(size_t idx);
- // Warning, this can be slow as it's removing items from a std::vector.
- bool
- DeleteSection (size_t idx);
+ lldb::SectionSP GetSectionAtIndex(size_t idx) const;
- lldb::SectionSP
- GetSectionAtIndex (size_t idx) const;
+ size_t Slide(lldb::addr_t slide_amount, bool slide_children);
- size_t
- Slide (lldb::addr_t slide_amount, bool slide_children);
-
- void
- Clear ()
- {
- m_sections.clear();
- }
+ void Clear() { m_sections.clear(); }
protected:
- collection m_sections;
+ collection m_sections;
};
-
-class Section :
- public std::enable_shared_from_this<Section>,
- public ModuleChild,
- public UserID,
- public Flags
-{
+class Section : public std::enable_shared_from_this<Section>,
+ public ModuleChild,
+ public UserID,
+ public Flags {
public:
- // Create a root section (one that has no parent)
- Section (const lldb::ModuleSP &module_sp,
- ObjectFile *obj_file,
- lldb::user_id_t sect_id,
- const ConstString &name,
- lldb::SectionType sect_type,
- lldb::addr_t file_vm_addr,
- lldb::addr_t vm_size,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- uint32_t log2align,
- uint32_t flags,
- uint32_t target_byte_size = 1);
-
- // Create a section that is a child of parent_section_sp
- Section (const lldb::SectionSP &parent_section_sp, // NULL for top level sections, non-NULL for child sections
- const lldb::ModuleSP &module_sp,
- ObjectFile *obj_file,
- lldb::user_id_t sect_id,
- const ConstString &name,
- lldb::SectionType sect_type,
- lldb::addr_t file_vm_addr,
- lldb::addr_t vm_size,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- uint32_t log2align,
- uint32_t flags,
- uint32_t target_byte_size = 1);
-
- ~Section ();
-
- static int
- Compare (const Section& a, const Section& b);
-
- bool
- ContainsFileAddress (lldb::addr_t vm_addr) const;
-
- SectionList&
- GetChildren ()
- {
- return m_children;
- }
-
- const SectionList&
- GetChildren () const
- {
- return m_children;
- }
-
- void
- Dump (Stream *s, Target *target, uint32_t depth) const;
-
- void
- DumpName (Stream *s) const;
-
- lldb::addr_t
- GetLoadBaseAddress (Target *target) const;
-
- bool
- ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const;
-
- lldb::offset_t
- GetFileOffset () const
- {
- return m_file_offset;
- }
-
- void
- SetFileOffset (lldb::offset_t file_offset)
- {
- m_file_offset = file_offset;
- }
-
- lldb::offset_t
- GetFileSize () const
- {
- return m_file_size;
- }
-
- void
- SetFileSize (lldb::offset_t file_size)
- {
- m_file_size = file_size;
- }
-
- lldb::addr_t
- GetFileAddress () const;
-
- bool
- SetFileAddress (lldb::addr_t file_addr);
-
- lldb::addr_t
- GetOffset () const;
-
-
- lldb::addr_t
- GetByteSize () const
- {
- return m_byte_size;
- }
-
- void
- SetByteSize (lldb::addr_t byte_size)
- {
- m_byte_size = byte_size;
- }
-
- bool
- IsFake() const
- {
- return m_fake;
- }
-
- void
- SetIsFake(bool fake)
- {
- m_fake = fake;
- }
-
- bool
- IsEncrypted () const
- {
- return m_encrypted;
- }
-
- void
- SetIsEncrypted (bool b)
- {
- m_encrypted = b;
- }
-
- bool
- IsDescendant (const Section *section);
-
- const ConstString&
- GetName () const
- {
- return m_name;
- }
-
- bool
- Slide (lldb::addr_t slide_amount, bool slide_children);
-
-
- lldb::SectionType
- GetType () const
- {
- return m_type;
- }
-
- lldb::SectionSP
- GetParent () const
- {
- return m_parent_wp.lock();
- }
-
- bool
- IsThreadSpecific () const
- {
- return m_thread_specific;
- }
-
- void
- SetIsThreadSpecific (bool b)
- {
- m_thread_specific = b;
- }
-
- //------------------------------------------------------------------
- /// Get the permissions as OR'ed bits from lldb::Permissions
- //------------------------------------------------------------------
- uint32_t
- GetPermissions() const;
-
- //------------------------------------------------------------------
- /// Set the permissions using bits OR'ed from lldb::Permissions
- //------------------------------------------------------------------
- void
- SetPermissions(uint32_t permissions);
-
- ObjectFile *
- GetObjectFile ()
- {
- return m_obj_file;
- }
- const ObjectFile *
- GetObjectFile () const
- {
- return m_obj_file;
- }
-
- //------------------------------------------------------------------
- /// Read the section data from the object file that the section
- /// resides in.
- ///
- /// @param[in] dst
- /// Where to place the data
- ///
- /// @param[in] dst_len
- /// How many bytes of section data to read
- ///
- /// @param[in] offset
- /// The offset in bytes within this section's data at which to
- /// start copying data from.
- ///
- /// @return
- /// The number of bytes read from the section, or zero if the
- /// section has no data or \a offset is not a valid offset
- /// in this section.
- //------------------------------------------------------------------
- lldb::offset_t
- GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0);
-
- //------------------------------------------------------------------
- /// Get the shared reference to the section data from the object
- /// file that the section resides in. No copies of the data will be
- /// make unless the object file has been read from memory. If the
- /// object file is on disk, it will shared the mmap data for the
- /// entire object file.
- ///
- /// @param[in] data
- /// Where to place the data, address byte size, and byte order
- ///
- /// @return
- /// The number of bytes read from the section, or zero if the
- /// section has no data or \a offset is not a valid offset
- /// in this section.
- //------------------------------------------------------------------
- lldb::offset_t
- GetSectionData (DataExtractor& data) const;
-
- uint32_t GetLog2Align()
- {
- return m_log2align;
- }
-
- void
- SetLog2Align(uint32_t align)
- {
- m_log2align = align;
- }
-
- // Get the number of host bytes required to hold a target byte
- uint32_t
- GetTargetByteSize() const
- {
- return m_target_byte_size;
- }
+ // Create a root section (one that has no parent)
+ Section(const lldb::ModuleSP &module_sp, ObjectFile *obj_file,
+ lldb::user_id_t sect_id, const ConstString &name,
+ lldb::SectionType sect_type, lldb::addr_t file_vm_addr,
+ lldb::addr_t vm_size, lldb::offset_t file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
+ uint32_t target_byte_size = 1);
-protected:
+ // Create a section that is a child of parent_section_sp
+ Section(const lldb::SectionSP &parent_section_sp, // NULL for top level
+ // sections, non-NULL for
+ // child sections
+ const lldb::ModuleSP &module_sp, ObjectFile *obj_file,
+ lldb::user_id_t sect_id, const ConstString &name,
+ lldb::SectionType sect_type, lldb::addr_t file_vm_addr,
+ lldb::addr_t vm_size, lldb::offset_t file_offset,
+ lldb::offset_t file_size, uint32_t log2align, uint32_t flags,
+ uint32_t target_byte_size = 1);
+
+ ~Section();
+
+ static int Compare(const Section &a, const Section &b);
+
+ bool ContainsFileAddress(lldb::addr_t vm_addr) const;
+
+ SectionList &GetChildren() { return m_children; }
+
+ const SectionList &GetChildren() const { return m_children; }
+
+ void Dump(Stream *s, Target *target, uint32_t depth) const;
+
+ void DumpName(Stream *s) const;
+
+ lldb::addr_t GetLoadBaseAddress(Target *target) const;
+
+ bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr) const;
+
+ lldb::offset_t GetFileOffset() const { return m_file_offset; }
+
+ void SetFileOffset(lldb::offset_t file_offset) {
+ m_file_offset = file_offset;
+ }
+
+ lldb::offset_t GetFileSize() const { return m_file_size; }
+
+ void SetFileSize(lldb::offset_t file_size) { m_file_size = file_size; }
+
+ lldb::addr_t GetFileAddress() const;
+
+ bool SetFileAddress(lldb::addr_t file_addr);
+
+ lldb::addr_t GetOffset() const;
- ObjectFile *m_obj_file; // The object file that data for this section should be read from
- lldb::SectionType m_type; // The type of this section
- lldb::SectionWP m_parent_wp; // Weak pointer to parent section
- ConstString m_name; // Name of this section
- lldb::addr_t m_file_addr; // The absolute file virtual address range of this section if m_parent == NULL,
- // offset from parent file virtual address if m_parent != NULL
- lldb::addr_t m_byte_size; // Size in bytes that this section will occupy in memory at runtime
- lldb::offset_t m_file_offset; // Object file offset (if any)
- lldb::offset_t m_file_size; // Object file size (can be smaller than m_byte_size for zero filled sections...)
- uint32_t m_log2align; // log_2(align) of the section (i.e. section has to be aligned to 2^m_log2align)
- SectionList m_children; // Child sections
- bool m_fake : 1, // If true, then this section only can contain the address if one of its
- // children contains an address. This allows for gaps between the children
- // that are contained in the address range for this section, but do not produce
- // hits unless the children contain the address.
- m_encrypted : 1, // Set to true if the contents are encrypted
- m_thread_specific : 1, // This section is thread specific
- m_readable : 1, // If this section has read permissions
- m_writable : 1, // If this section has write permissions
- m_executable : 1; // If this section has executable permissions
- uint32_t m_target_byte_size; // Some architectures have non-8-bit byte size. This is specified as
- // as a multiple number of a host bytes
+ lldb::addr_t GetByteSize() const { return m_byte_size; }
+
+ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; }
+
+ bool IsFake() const { return m_fake; }
+
+ void SetIsFake(bool fake) { m_fake = fake; }
+
+ bool IsEncrypted() const { return m_encrypted; }
+
+ void SetIsEncrypted(bool b) { m_encrypted = b; }
+
+ bool IsDescendant(const Section *section);
+
+ const ConstString &GetName() const { return m_name; }
+
+ bool Slide(lldb::addr_t slide_amount, bool slide_children);
+
+ lldb::SectionType GetType() const { return m_type; }
+
+ lldb::SectionSP GetParent() const { return m_parent_wp.lock(); }
+
+ bool IsThreadSpecific() const { return m_thread_specific; }
+
+ void SetIsThreadSpecific(bool b) { m_thread_specific = b; }
+
+ //------------------------------------------------------------------
+ /// Get the permissions as OR'ed bits from lldb::Permissions
+ //------------------------------------------------------------------
+ uint32_t GetPermissions() const;
+
+ //------------------------------------------------------------------
+ /// Set the permissions using bits OR'ed from lldb::Permissions
+ //------------------------------------------------------------------
+ void SetPermissions(uint32_t permissions);
+
+ ObjectFile *GetObjectFile() { return m_obj_file; }
+ const ObjectFile *GetObjectFile() const { return m_obj_file; }
+
+ //------------------------------------------------------------------
+ /// Read the section data from the object file that the section
+ /// resides in.
+ ///
+ /// @param[in] dst
+ /// Where to place the data
+ ///
+ /// @param[in] dst_len
+ /// How many bytes of section data to read
+ ///
+ /// @param[in] offset
+ /// The offset in bytes within this section's data at which to
+ /// start copying data from.
+ ///
+ /// @return
+ /// The number of bytes read from the section, or zero if the
+ /// section has no data or \a offset is not a valid offset
+ /// in this section.
+ //------------------------------------------------------------------
+ lldb::offset_t GetSectionData(void *dst, lldb::offset_t dst_len,
+ lldb::offset_t offset = 0);
+
+ //------------------------------------------------------------------
+ /// Get the shared reference to the section data from the object
+ /// file that the section resides in. No copies of the data will be
+ /// make unless the object file has been read from memory. If the
+ /// object file is on disk, it will shared the mmap data for the
+ /// entire object file.
+ ///
+ /// @param[in] data
+ /// Where to place the data, address byte size, and byte order
+ ///
+ /// @return
+ /// The number of bytes read from the section, or zero if the
+ /// section has no data or \a offset is not a valid offset
+ /// in this section.
+ //------------------------------------------------------------------
+ lldb::offset_t GetSectionData(DataExtractor &data) const;
+
+ uint32_t GetLog2Align() { return m_log2align; }
+
+ void SetLog2Align(uint32_t align) { m_log2align = align; }
+
+ // Get the number of host bytes required to hold a target byte
+ uint32_t GetTargetByteSize() const { return m_target_byte_size; }
+
+protected:
+ ObjectFile *m_obj_file; // The object file that data for this section should
+ // be read from
+ lldb::SectionType m_type; // The type of this section
+ lldb::SectionWP m_parent_wp; // Weak pointer to parent section
+ ConstString m_name; // Name of this section
+ lldb::addr_t m_file_addr; // The absolute file virtual address range of this
+ // section if m_parent == NULL,
+ // offset from parent file virtual address if m_parent != NULL
+ lldb::addr_t m_byte_size; // Size in bytes that this section will occupy in
+ // memory at runtime
+ lldb::offset_t m_file_offset; // Object file offset (if any)
+ lldb::offset_t m_file_size; // Object file size (can be smaller than
+ // m_byte_size for zero filled sections...)
+ uint32_t m_log2align; // log_2(align) of the section (i.e. section has to be
+ // aligned to 2^m_log2align)
+ SectionList m_children; // Child sections
+ bool m_fake : 1, // If true, then this section only can contain the address if
+ // one of its
+ // children contains an address. This allows for gaps between the children
+ // that are contained in the address range for this section, but do not
+ // produce
+ // hits unless the children contain the address.
+ m_encrypted : 1, // Set to true if the contents are encrypted
+ m_thread_specific : 1, // This section is thread specific
+ m_readable : 1, // If this section has read permissions
+ m_writable : 1, // If this section has write permissions
+ m_executable : 1; // If this section has executable permissions
+ uint32_t m_target_byte_size; // Some architectures have non-8-bit byte size.
+ // This is specified as
+ // as a multiple number of a host bytes
private:
- DISALLOW_COPY_AND_ASSIGN (Section);
+ DISALLOW_COPY_AND_ASSIGN(Section);
};
-
} // namespace lldb_private
-#endif // liblldb_Section_h_
+#endif // liblldb_Section_h_
Modified: lldb/trunk/include/lldb/Core/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/SourceManager.h (original)
+++ lldb/trunk/include/lldb/Core/SourceManager.h Tue Sep 6 15:57:50 2016
@@ -18,179 +18,141 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class SourceManager
-{
+class SourceManager {
public:
#ifndef SWIG
- class File
- {
- friend bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
-
- public:
- File (const FileSpec &file_spec, Target *target);
- ~File();
-
- void
- UpdateIfNeeded ();
-
- size_t
- DisplaySourceLines (uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- Stream *s);
- void
- FindLinesMatchingRegex (RegularExpression& regex,
- uint32_t start_line,
- uint32_t end_line,
+ class File {
+ friend bool operator==(const SourceManager::File &lhs,
+ const SourceManager::File &rhs);
+
+ public:
+ File(const FileSpec &file_spec, Target *target);
+ ~File();
+
+ void UpdateIfNeeded();
+
+ size_t DisplaySourceLines(uint32_t line, uint32_t context_before,
+ uint32_t context_after, Stream *s);
+ void FindLinesMatchingRegex(RegularExpression ®ex, uint32_t start_line,
+ uint32_t end_line,
std::vector<uint32_t> &match_lines);
- bool
- GetLine (uint32_t line_no, std::string &buffer);
-
- uint32_t
- GetLineOffset (uint32_t line);
-
- bool
- LineIsValid (uint32_t line);
-
- bool
- FileSpecMatches (const FileSpec &file_spec);
-
- const FileSpec &
- GetFileSpec ()
- {
- return m_file_spec;
- }
-
- uint32_t
- GetSourceMapModificationID() const
- {
- return m_source_map_mod_id;
- }
-
- const char *
- PeekLineData (uint32_t line);
-
- uint32_t
- GetLineLength (uint32_t line, bool include_newline_chars);
-
- uint32_t
- GetNumLines ();
-
- protected:
- bool
- CalculateLineOffsets (uint32_t line = UINT32_MAX);
-
- FileSpec m_file_spec_orig; // The original file spec that was used (can be different from m_file_spec)
- FileSpec m_file_spec; // The actually file spec being used (if the target has source mappings, this might be different from m_file_spec_orig)
- TimeValue m_mod_time; // Keep the modification time that this file data is valid for
- uint32_t m_source_map_mod_id; // If the target uses path remappings, be sure to clear our notion of a source file if the path modification ID changes
- lldb::DataBufferSP m_data_sp;
- typedef std::vector<uint32_t> LineOffsets;
- LineOffsets m_offsets;
- };
+ bool GetLine(uint32_t line_no, std::string &buffer);
+
+ uint32_t GetLineOffset(uint32_t line);
+
+ bool LineIsValid(uint32_t line);
+
+ bool FileSpecMatches(const FileSpec &file_spec);
+
+ const FileSpec &GetFileSpec() { return m_file_spec; }
+
+ uint32_t GetSourceMapModificationID() const { return m_source_map_mod_id; }
+
+ const char *PeekLineData(uint32_t line);
+
+ uint32_t GetLineLength(uint32_t line, bool include_newline_chars);
+
+ uint32_t GetNumLines();
+
+ protected:
+ bool CalculateLineOffsets(uint32_t line = UINT32_MAX);
+
+ FileSpec m_file_spec_orig; // The original file spec that was used (can be
+ // different from m_file_spec)
+ FileSpec m_file_spec; // The actually file spec being used (if the target
+ // has source mappings, this might be different from
+ // m_file_spec_orig)
+ TimeValue m_mod_time; // Keep the modification time that this file data is
+ // valid for
+ uint32_t m_source_map_mod_id; // If the target uses path remappings, be sure
+ // to clear our notion of a source file if the
+ // path modification ID changes
+ lldb::DataBufferSP m_data_sp;
+ typedef std::vector<uint32_t> LineOffsets;
+ LineOffsets m_offsets;
+ };
#endif // SWIG
- typedef std::shared_ptr<File> FileSP;
+ typedef std::shared_ptr<File> FileSP;
#ifndef SWIG
- // The SourceFileCache class separates the source manager from the cache of source files, so the
- // cache can be stored in the Debugger, but the source managers can be per target.
- class SourceFileCache
- {
- public:
- SourceFileCache() = default;
- ~SourceFileCache() = default;
-
- void AddSourceFile (const FileSP &file_sp);
- FileSP FindSourceFile (const FileSpec &file_spec) const;
-
- protected:
- typedef std::map <FileSpec, FileSP> FileCache;
- FileCache m_file_cache;
- };
+ // The SourceFileCache class separates the source manager from the cache of
+ // source files, so the
+ // cache can be stored in the Debugger, but the source managers can be per
+ // target.
+ class SourceFileCache {
+ public:
+ SourceFileCache() = default;
+ ~SourceFileCache() = default;
+
+ void AddSourceFile(const FileSP &file_sp);
+ FileSP FindSourceFile(const FileSpec &file_spec) const;
+
+ protected:
+ typedef std::map<FileSpec, FileSP> FileCache;
+ FileCache m_file_cache;
+ };
#endif // SWIG
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- // A source manager can be made with a non-null target, in which case it can use the path remappings to find
- // source files that are not in their build locations. With no target it won't be able to do this.
- SourceManager (const lldb::DebuggerSP &debugger_sp);
- SourceManager (const lldb::TargetSP &target_sp);
-
- ~SourceManager();
-
- FileSP
- GetLastFile ()
- {
- return m_last_file_sp;
- }
-
- size_t
- DisplaySourceLinesWithLineNumbers(const FileSpec &file,
- uint32_t line,
- uint32_t context_before,
- uint32_t context_after,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs = nullptr);
-
- // This variant uses the last file we visited.
- size_t
- DisplaySourceLinesWithLineNumbersUsingLastFile(uint32_t start_line,
- uint32_t count,
- uint32_t curr_line,
- const char* current_line_cstr,
- Stream *s,
- const SymbolContextList *bp_locs = nullptr);
-
- size_t
- DisplayMoreWithLineNumbers(Stream *s,
- uint32_t count,
- bool reverse,
- const SymbolContextList *bp_locs = nullptr);
-
- bool
- SetDefaultFileAndLine (const FileSpec &file_spec, uint32_t line);
-
- bool
- GetDefaultFileAndLine (FileSpec &file_spec, uint32_t &line);
-
- bool
- DefaultFileAndLineSet ()
- {
- return (m_last_file_sp.get() != nullptr);
- }
-
- void
- FindLinesMatchingRegex (FileSpec &file_spec,
- RegularExpression& regex,
- uint32_t start_line,
- uint32_t end_line,
- std::vector<uint32_t> &match_lines);
-
- FileSP
- GetFile (const FileSpec &file_spec);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ // A source manager can be made with a non-null target, in which case it can
+ // use the path remappings to find
+ // source files that are not in their build locations. With no target it
+ // won't be able to do this.
+ SourceManager(const lldb::DebuggerSP &debugger_sp);
+ SourceManager(const lldb::TargetSP &target_sp);
+
+ ~SourceManager();
+
+ FileSP GetLastFile() { return m_last_file_sp; }
+
+ size_t DisplaySourceLinesWithLineNumbers(
+ const FileSpec &file, uint32_t line, uint32_t context_before,
+ uint32_t context_after, const char *current_line_cstr, Stream *s,
+ const SymbolContextList *bp_locs = nullptr);
+
+ // This variant uses the last file we visited.
+ size_t DisplaySourceLinesWithLineNumbersUsingLastFile(
+ uint32_t start_line, uint32_t count, uint32_t curr_line,
+ const char *current_line_cstr, Stream *s,
+ const SymbolContextList *bp_locs = nullptr);
+
+ size_t DisplayMoreWithLineNumbers(Stream *s, uint32_t count, bool reverse,
+ const SymbolContextList *bp_locs = nullptr);
+
+ bool SetDefaultFileAndLine(const FileSpec &file_spec, uint32_t line);
+
+ bool GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line);
+
+ bool DefaultFileAndLineSet() { return (m_last_file_sp.get() != nullptr); }
+
+ void FindLinesMatchingRegex(FileSpec &file_spec, RegularExpression ®ex,
+ uint32_t start_line, uint32_t end_line,
+ std::vector<uint32_t> &match_lines);
+
+ FileSP GetFile(const FileSpec &file_spec);
protected:
- FileSP m_last_file_sp;
- uint32_t m_last_line;
- uint32_t m_last_count;
- bool m_default_set;
- lldb::TargetWP m_target_wp;
- lldb::DebuggerWP m_debugger_wp;
-
+ FileSP m_last_file_sp;
+ uint32_t m_last_line;
+ uint32_t m_last_count;
+ bool m_default_set;
+ lldb::TargetWP m_target_wp;
+ lldb::DebuggerWP m_debugger_wp;
+
private:
- DISALLOW_COPY_AND_ASSIGN (SourceManager);
+ DISALLOW_COPY_AND_ASSIGN(SourceManager);
};
-bool operator== (const SourceManager::File &lhs, const SourceManager::File &rhs);
+bool operator==(const SourceManager::File &lhs, const SourceManager::File &rhs);
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/State.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/State.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/State.h (original)
+++ lldb/trunk/include/lldb/Core/State.h Tue Sep 6 15:57:50 2016
@@ -29,8 +29,7 @@ namespace lldb_private {
/// returned string comes from constant string buffers and does
/// not need to be freed.
//------------------------------------------------------------------
-const char *
-StateAsCString (lldb::StateType state);
+const char *StateAsCString(lldb::StateType state);
//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
@@ -43,13 +42,12 @@ StateAsCString (lldb::StateType state);
/// \b true if the state represents a process or thread state
/// where the process or thread is running, \b false otherwise.
//------------------------------------------------------------------
-bool
-StateIsRunningState (lldb::StateType state);
+bool StateIsRunningState(lldb::StateType state);
//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
/// is stopped. Stopped can mean stopped when the process is still
-/// around, or stopped when the process has exited or doesn't exist
+/// around, or stopped when the process has exited or doesn't exist
/// yet. The \a must_exist argument tells us which of these cases is
/// desired.
///
@@ -62,17 +60,15 @@ StateIsRunningState (lldb::StateType sta
///
/// @return
/// \b true if the state represents a process or thread state
-/// where the process or thread is stopped. If \a must_exist is
+/// where the process or thread is stopped. If \a must_exist is
/// \b true, then the process can't be exited or unloaded,
/// otherwise exited and unloaded or other states where the
-/// process no longer exists are considered to be stopped.
+/// process no longer exists are considered to be stopped.
//------------------------------------------------------------------
-bool
-StateIsStoppedState (lldb::StateType state, bool must_exist);
+bool StateIsStoppedState(lldb::StateType state, bool must_exist);
+
+const char *GetPermissionsAsCString(uint32_t permissions);
-const char *
-GetPermissionsAsCString (uint32_t permissions);
-
} // namespace lldb_private
-#endif // liblldb_State_h_
+#endif // liblldb_State_h_
Modified: lldb/trunk/include/lldb/Core/Stream.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Stream.h (original)
+++ lldb/trunk/include/lldb/Core/Stream.h Tue Sep 6 15:57:50 2016
@@ -16,8 +16,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/Flags.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -25,590 +25,537 @@ namespace lldb_private {
/// @class Stream Stream.h "lldb/Core/Stream.h"
/// @brief A stream class that can stream formatted output to a file.
//----------------------------------------------------------------------
-class Stream
-{
+class Stream {
public:
- //------------------------------------------------------------------
- /// \a m_flags bit values.
- //------------------------------------------------------------------
- enum
- {
- eVerbose = (1 << 0), ///< If set, verbose logging is enabled
- eDebug = (1 << 1), ///< If set, debug logging is enabled
- eAddPrefix = (1 << 2), ///< Add number prefixes for binary, octal and hex when eBinary is clear
- eBinary = (1 << 3) ///< Get and put data as binary instead of as the default string mode.
- };
-
- //------------------------------------------------------------------
- /// Construct with flags and address size and byte order.
- ///
- /// Construct with dump flags \a flags and the default address
- /// size. \a flags can be any of the above enumeration logical OR'ed
- /// together.
- //------------------------------------------------------------------
- Stream (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Construct a default Stream, not binary, host byte order and
- /// host addr size.
- ///
- //------------------------------------------------------------------
- Stream ();
-
- //------------------------------------------------------------------
- /// Destructor
- //------------------------------------------------------------------
- virtual
- ~Stream ();
-
- //------------------------------------------------------------------
- // Subclasses must override these methods
- //------------------------------------------------------------------
-
- //------------------------------------------------------------------
- /// Flush the stream.
- ///
- /// Subclasses should flush the stream to make any output appear
- /// if the stream has any buffering.
- //------------------------------------------------------------------
- virtual void
- Flush () = 0;
-
- //------------------------------------------------------------------
- /// Output character bytes to the stream.
- ///
- /// Appends \a src_len characters from the buffer \a src to the
- /// stream.
- ///
- /// @param[in] src
- /// A buffer containing at least \a src_len bytes of data.
- ///
- /// @param[in] src_len
- /// A number of bytes to append to the stream.
- ///
- /// @return
- /// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
- virtual size_t
- Write (const void *src, size_t src_len) = 0;
-
- //------------------------------------------------------------------
- // Member functions
- //------------------------------------------------------------------
- size_t
- PutChar (char ch);
-
- //------------------------------------------------------------------
- /// Set the byte_order value.
- ///
- /// Sets the byte order of the data to extract. Extracted values
- /// will be swapped if necessary when decoding.
- ///
- /// @param[in] byte_order
- /// The byte order value to use when extracting data.
- ///
- /// @return
- /// The old byte order value.
- //------------------------------------------------------------------
- lldb::ByteOrder
- SetByteOrder (lldb::ByteOrder byte_order);
-
- //------------------------------------------------------------------
- /// Format a C string from a printf style format and variable
- /// arguments and encode and append the resulting C string as hex
- /// bytes.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Any additional arguments needed for the printf format string.
- ///
- /// @return
- /// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
- size_t
- PrintfAsRawHex8 (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- //------------------------------------------------------------------
- /// Format a C string from a printf style format and variable
- /// arguments and encode and append the resulting C string as hex
- /// bytes.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Any additional arguments needed for the printf format string.
- ///
- /// @return
- /// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
- size_t
- PutHex8 (uint8_t uvalue);
-
- size_t
- PutNHex8 (size_t n, uint8_t uvalue);
-
- size_t
- PutHex16 (uint16_t uvalue,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutHex32 (uint32_t uvalue,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutHex64 (uint64_t uvalue,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutMaxHex64 (uint64_t uvalue,
- size_t byte_size,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
- size_t
- PutFloat (float f,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutDouble (double d,
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+ //------------------------------------------------------------------
+ /// \a m_flags bit values.
+ //------------------------------------------------------------------
+ enum {
+ eVerbose = (1 << 0), ///< If set, verbose logging is enabled
+ eDebug = (1 << 1), ///< If set, debug logging is enabled
+ eAddPrefix = (1 << 2), ///< Add number prefixes for binary, octal and hex
+ ///when eBinary is clear
+ eBinary = (1 << 3) ///< Get and put data as binary instead of as the default
+ ///string mode.
+ };
+
+ //------------------------------------------------------------------
+ /// Construct with flags and address size and byte order.
+ ///
+ /// Construct with dump flags \a flags and the default address
+ /// size. \a flags can be any of the above enumeration logical OR'ed
+ /// together.
+ //------------------------------------------------------------------
+ Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Construct a default Stream, not binary, host byte order and
+ /// host addr size.
+ ///
+ //------------------------------------------------------------------
+ Stream();
+
+ //------------------------------------------------------------------
+ /// Destructor
+ //------------------------------------------------------------------
+ virtual ~Stream();
+
+ //------------------------------------------------------------------
+ // Subclasses must override these methods
+ //------------------------------------------------------------------
+
+ //------------------------------------------------------------------
+ /// Flush the stream.
+ ///
+ /// Subclasses should flush the stream to make any output appear
+ /// if the stream has any buffering.
+ //------------------------------------------------------------------
+ virtual void Flush() = 0;
+
+ //------------------------------------------------------------------
+ /// Output character bytes to the stream.
+ ///
+ /// Appends \a src_len characters from the buffer \a src to the
+ /// stream.
+ ///
+ /// @param[in] src
+ /// A buffer containing at least \a src_len bytes of data.
+ ///
+ /// @param[in] src_len
+ /// A number of bytes to append to the stream.
+ ///
+ /// @return
+ /// The number of bytes that were appended to the stream.
+ //------------------------------------------------------------------
+ virtual size_t Write(const void *src, size_t src_len) = 0;
+
+ //------------------------------------------------------------------
+ // Member functions
+ //------------------------------------------------------------------
+ size_t PutChar(char ch);
+
+ //------------------------------------------------------------------
+ /// Set the byte_order value.
+ ///
+ /// Sets the byte order of the data to extract. Extracted values
+ /// will be swapped if necessary when decoding.
+ ///
+ /// @param[in] byte_order
+ /// The byte order value to use when extracting data.
+ ///
+ /// @return
+ /// The old byte order value.
+ //------------------------------------------------------------------
+ lldb::ByteOrder SetByteOrder(lldb::ByteOrder byte_order);
+
+ //------------------------------------------------------------------
+ /// Format a C string from a printf style format and variable
+ /// arguments and encode and append the resulting C string as hex
+ /// bytes.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Any additional arguments needed for the printf format string.
+ ///
+ /// @return
+ /// The number of bytes that were appended to the stream.
+ //------------------------------------------------------------------
+ size_t PrintfAsRawHex8(const char *format, ...)
+ __attribute__((format(printf, 2, 3)));
+
+ //------------------------------------------------------------------
+ /// Format a C string from a printf style format and variable
+ /// arguments and encode and append the resulting C string as hex
+ /// bytes.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Any additional arguments needed for the printf format string.
+ ///
+ /// @return
+ /// The number of bytes that were appended to the stream.
+ //------------------------------------------------------------------
+ size_t PutHex8(uint8_t uvalue);
+
+ size_t PutNHex8(size_t n, uint8_t uvalue);
+
+ size_t PutHex16(uint16_t uvalue,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutHex32(uint32_t uvalue,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutHex64(uint64_t uvalue,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutMaxHex64(uint64_t uvalue, size_t byte_size,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+ size_t PutFloat(float f,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
- size_t
- PutLongDouble (long double ld,
+ size_t PutDouble(double d,
lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
- size_t
- PutPointer (void *ptr);
+ size_t PutLongDouble(long double ld,
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutPointer(void *ptr);
- // Append \a src_len bytes from \a src to the stream as hex characters
- // (two ascii characters per byte of input data)
- size_t
- PutBytesAsRawHex8 (const void *src,
- size_t src_len,
- lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
- lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
-
- // Append \a src_len bytes from \a s to the stream as binary data.
- size_t
- PutRawBytes (const void *s,
- size_t src_len,
- lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
- lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
-
- size_t
- PutCStringAsRawHex8 (const char *s);
-
- //------------------------------------------------------------------
- /// Output a NULL terminated C string \a cstr to the stream \a s.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (const char *cstr);
-
- //------------------------------------------------------------------
- /// Output a pointer value \a p to the stream \a s.
- ///
- /// @param[in] p
- /// A void pointer.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (const void *p);
-
- //------------------------------------------------------------------
- /// Output a character \a ch to the stream \a s.
- ///
- /// @param[in] ch
- /// A printable character value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (char ch);
-
- //------------------------------------------------------------------
- /// Output a uint8_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint8_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint8_t uval);
-
- //------------------------------------------------------------------
- /// Output a uint16_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint16_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint16_t uval);
-
- //------------------------------------------------------------------
- /// Output a uint32_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint32_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint32_t uval);
-
- //------------------------------------------------------------------
- /// Output a uint64_t \a uval to the stream \a s.
- ///
- /// @param[in] uval
- /// A uint64_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (uint64_t uval);
-
- //------------------------------------------------------------------
- /// Output a int8_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int8_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int8_t sval);
-
- //------------------------------------------------------------------
- /// Output a int16_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int16_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int16_t sval);
-
- //------------------------------------------------------------------
- /// Output a int32_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int32_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int32_t sval);
-
- //------------------------------------------------------------------
- /// Output a int64_t \a sval to the stream \a s.
- ///
- /// @param[in] sval
- /// A int64_t value.
- ///
- /// @return
- /// A reference to this class so multiple things can be streamed
- /// in one statement.
- //------------------------------------------------------------------
- Stream&
- operator<< (int64_t sval);
-
- //------------------------------------------------------------------
- /// Output an address value to this stream.
- ///
- /// Put an address \a addr out to the stream with optional \a prefix
- /// and \a suffix strings.
- ///
- /// @param[in] addr
- /// An address value.
- ///
- /// @param[in] addr_size
- /// Size in bytes of the address, used for formatting.
- ///
- /// @param[in] prefix
- /// A prefix C string. If nullptr, no prefix will be output.
- ///
- /// @param[in] suffix
- /// A suffix C string. If nullptr, no suffix will be output.
- //------------------------------------------------------------------
- void
- Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr);
-
- //------------------------------------------------------------------
- /// Output an address range to this stream.
- ///
- /// Put an address range \a lo_addr - \a hi_addr out to the stream
- /// with optional \a prefix and \a suffix strings.
- ///
- /// @param[in] lo_addr
- /// The start address of the address range.
- ///
- /// @param[in] hi_addr
- /// The end address of the address range.
- ///
- /// @param[in] addr_size
- /// Size in bytes of the address, used for formatting.
- ///
- /// @param[in] prefix
- /// A prefix C string. If nullptr, no prefix will be output.
- ///
- /// @param[in] suffix
- /// A suffix C string. If nullptr, no suffix will be output.
- //------------------------------------------------------------------
- void
- AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix = nullptr, const char *suffix = nullptr);
-
- //------------------------------------------------------------------
- /// Output a C string to the stream.
- ///
- /// Print a C string \a cstr to the stream.
- ///
- /// @param[in] cstr
- /// The string to be output to the stream.
- //------------------------------------------------------------------
- size_t
- PutCString (const char *cstr);
-
- //------------------------------------------------------------------
- /// Output and End of Line character to the stream.
- //------------------------------------------------------------------
- size_t
- EOL();
-
- //------------------------------------------------------------------
- /// Get the address size in bytes.
- ///
- /// @return
- /// The size of an address in bytes that is used when outputting
- /// address and pointer values to the stream.
- //------------------------------------------------------------------
- uint32_t
- GetAddressByteSize () const;
-
- //------------------------------------------------------------------
- /// Test if debug logging is enabled.
- ///
- /// @return
- // \b true if the debug flag bit is set in this stream, \b
- // false otherwise.
- //------------------------------------------------------------------
- bool
- GetDebug() const;
-
- //------------------------------------------------------------------
- /// The flags accessor.
- ///
- /// @return
- /// A reference to the Flags member variable.
- //------------------------------------------------------------------
- Flags&
- GetFlags();
-
- //------------------------------------------------------------------
- /// The flags const accessor.
- ///
- /// @return
- /// A const reference to the Flags member variable.
- //------------------------------------------------------------------
- const Flags&
- GetFlags() const;
-
- //------------------------------------------------------------------
- //// The byte order accessor.
- ////
- //// @return
- //// The byte order.
- //------------------------------------------------------------------
- lldb::ByteOrder
- GetByteOrder() const;
-
- //------------------------------------------------------------------
- /// Get the current indentation level.
- ///
- /// @return
- /// The current indentation level as an integer.
- //------------------------------------------------------------------
- int
- GetIndentLevel () const;
-
- //------------------------------------------------------------------
- /// Test if verbose logging is enabled.
- ///
- /// @return
- // \b true if the verbose flag bit is set in this stream, \b
- // false otherwise.
- //------------------------------------------------------------------
- bool
- GetVerbose() const;
-
- //------------------------------------------------------------------
- /// Indent the current line in the stream.
- ///
- /// Indent the current line using the current indentation level and
- /// print an optional string following the indentation spaces.
- ///
- /// @param[in] s
- /// A C string to print following the indentation. If nullptr, just
- /// output the indentation characters.
- //------------------------------------------------------------------
- size_t
- Indent(const char *s = nullptr);
-
- //------------------------------------------------------------------
- /// Decrement the current indentation level.
- //------------------------------------------------------------------
- void
- IndentLess (int amount = 2);
-
- //------------------------------------------------------------------
- /// Increment the current indentation level.
- //------------------------------------------------------------------
- void
- IndentMore (int amount = 2);
-
- //------------------------------------------------------------------
- /// Output an offset value.
- ///
- /// Put an offset \a uval out to the stream using the printf format
- /// in \a format.
- ///
- /// @param[in] offset
- /// The offset value.
- ///
- /// @param[in] format
- /// The printf style format to use when outputting the offset.
- //------------------------------------------------------------------
- void
- Offset (uint32_t offset, const char *format = "0x%8.8x: ");
-
- //------------------------------------------------------------------
- /// Output printf formatted output to the stream.
- ///
- /// Print some formatted output to the stream.
- ///
- /// @param[in] format
- /// A printf style format string.
- ///
- /// @param[in] ...
- /// Variable arguments that are needed for the printf style
- /// format string \a format.
- //------------------------------------------------------------------
- size_t
- Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-
- size_t
- PrintfVarArg(const char *format, va_list args);
-
- //------------------------------------------------------------------
- /// Output a quoted C string value to the stream.
- ///
- /// Print a double quoted NULL terminated C string to the stream
- /// using the printf format in \a format.
- ///
- /// @param[in] cstr
- /// A NULL terminated C string value.
- ///
- /// @param[in] format
- /// The optional C string format that can be overridden.
- //------------------------------------------------------------------
- void
- QuotedCString (const char *cstr, const char *format = "\"%s\"");
-
- //------------------------------------------------------------------
- /// Set the address size in bytes.
- ///
- /// @param[in] addr_size
- /// The new size in bytes of an address to use when outputting
- /// address and pointer values.
- //------------------------------------------------------------------
- void
- SetAddressByteSize (uint32_t addr_size);
-
- //------------------------------------------------------------------
- /// Set the current indentation level.
- ///
- /// @param[in] level
- /// The new indentation level.
- //------------------------------------------------------------------
- void
- SetIndentLevel (int level);
-
- //------------------------------------------------------------------
- /// Output a SLEB128 number to the stream.
- ///
- /// Put an SLEB128 \a uval out to the stream using the printf format
- /// in \a format.
- ///
- /// @param[in] uval
- /// A uint64_t value that was extracted as a SLEB128 value.
- ///
- /// @param[in] format
- /// The optional printf format that can be overridden.
- //------------------------------------------------------------------
- size_t
- PutSLEB128 (int64_t uval);
-
- //------------------------------------------------------------------
- /// Output a ULEB128 number to the stream.
- ///
- /// Put an ULEB128 \a uval out to the stream using the printf format
- /// in \a format.
- ///
- /// @param[in] uval
- /// A uint64_t value that was extracted as a ULEB128 value.
- ///
- /// @param[in] format
- /// The optional printf format that can be overridden.
- //------------------------------------------------------------------
- size_t
- PutULEB128 (uint64_t uval);
+ // Append \a src_len bytes from \a src to the stream as hex characters
+ // (two ascii characters per byte of input data)
+ size_t
+ PutBytesAsRawHex8(const void *src, size_t src_len,
+ lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
+ lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
+
+ // Append \a src_len bytes from \a s to the stream as binary data.
+ size_t PutRawBytes(const void *s, size_t src_len,
+ lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
+ lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
+
+ size_t PutCStringAsRawHex8(const char *s);
+
+ //------------------------------------------------------------------
+ /// Output a NULL terminated C string \a cstr to the stream \a s.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(const char *cstr);
+
+ //------------------------------------------------------------------
+ /// Output a pointer value \a p to the stream \a s.
+ ///
+ /// @param[in] p
+ /// A void pointer.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(const void *p);
+
+ //------------------------------------------------------------------
+ /// Output a character \a ch to the stream \a s.
+ ///
+ /// @param[in] ch
+ /// A printable character value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(char ch);
+
+ //------------------------------------------------------------------
+ /// Output a uint8_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint8_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint8_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a uint16_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint16_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint16_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a uint32_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint32_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint32_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a uint64_t \a uval to the stream \a s.
+ ///
+ /// @param[in] uval
+ /// A uint64_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(uint64_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a int8_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int8_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int8_t sval);
+
+ //------------------------------------------------------------------
+ /// Output a int16_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int16_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int16_t sval);
+
+ //------------------------------------------------------------------
+ /// Output a int32_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int32_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int32_t sval);
+
+ //------------------------------------------------------------------
+ /// Output a int64_t \a sval to the stream \a s.
+ ///
+ /// @param[in] sval
+ /// A int64_t value.
+ ///
+ /// @return
+ /// A reference to this class so multiple things can be streamed
+ /// in one statement.
+ //------------------------------------------------------------------
+ Stream &operator<<(int64_t sval);
+
+ //------------------------------------------------------------------
+ /// Output an address value to this stream.
+ ///
+ /// Put an address \a addr out to the stream with optional \a prefix
+ /// and \a suffix strings.
+ ///
+ /// @param[in] addr
+ /// An address value.
+ ///
+ /// @param[in] addr_size
+ /// Size in bytes of the address, used for formatting.
+ ///
+ /// @param[in] prefix
+ /// A prefix C string. If nullptr, no prefix will be output.
+ ///
+ /// @param[in] suffix
+ /// A suffix C string. If nullptr, no suffix will be output.
+ //------------------------------------------------------------------
+ void Address(uint64_t addr, uint32_t addr_size, const char *prefix = nullptr,
+ const char *suffix = nullptr);
+
+ //------------------------------------------------------------------
+ /// Output an address range to this stream.
+ ///
+ /// Put an address range \a lo_addr - \a hi_addr out to the stream
+ /// with optional \a prefix and \a suffix strings.
+ ///
+ /// @param[in] lo_addr
+ /// The start address of the address range.
+ ///
+ /// @param[in] hi_addr
+ /// The end address of the address range.
+ ///
+ /// @param[in] addr_size
+ /// Size in bytes of the address, used for formatting.
+ ///
+ /// @param[in] prefix
+ /// A prefix C string. If nullptr, no prefix will be output.
+ ///
+ /// @param[in] suffix
+ /// A suffix C string. If nullptr, no suffix will be output.
+ //------------------------------------------------------------------
+ void AddressRange(uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size,
+ const char *prefix = nullptr, const char *suffix = nullptr);
+
+ //------------------------------------------------------------------
+ /// Output a C string to the stream.
+ ///
+ /// Print a C string \a cstr to the stream.
+ ///
+ /// @param[in] cstr
+ /// The string to be output to the stream.
+ //------------------------------------------------------------------
+ size_t PutCString(const char *cstr);
+
+ //------------------------------------------------------------------
+ /// Output and End of Line character to the stream.
+ //------------------------------------------------------------------
+ size_t EOL();
+
+ //------------------------------------------------------------------
+ /// Get the address size in bytes.
+ ///
+ /// @return
+ /// The size of an address in bytes that is used when outputting
+ /// address and pointer values to the stream.
+ //------------------------------------------------------------------
+ uint32_t GetAddressByteSize() const;
+
+ //------------------------------------------------------------------
+ /// Test if debug logging is enabled.
+ ///
+ /// @return
+ // \b true if the debug flag bit is set in this stream, \b
+ // false otherwise.
+ //------------------------------------------------------------------
+ bool GetDebug() const;
+
+ //------------------------------------------------------------------
+ /// The flags accessor.
+ ///
+ /// @return
+ /// A reference to the Flags member variable.
+ //------------------------------------------------------------------
+ Flags &GetFlags();
+
+ //------------------------------------------------------------------
+ /// The flags const accessor.
+ ///
+ /// @return
+ /// A const reference to the Flags member variable.
+ //------------------------------------------------------------------
+ const Flags &GetFlags() const;
+
+ //------------------------------------------------------------------
+ //// The byte order accessor.
+ ////
+ //// @return
+ //// The byte order.
+ //------------------------------------------------------------------
+ lldb::ByteOrder GetByteOrder() const;
+
+ //------------------------------------------------------------------
+ /// Get the current indentation level.
+ ///
+ /// @return
+ /// The current indentation level as an integer.
+ //------------------------------------------------------------------
+ int GetIndentLevel() const;
+
+ //------------------------------------------------------------------
+ /// Test if verbose logging is enabled.
+ ///
+ /// @return
+ // \b true if the verbose flag bit is set in this stream, \b
+ // false otherwise.
+ //------------------------------------------------------------------
+ bool GetVerbose() const;
+
+ //------------------------------------------------------------------
+ /// Indent the current line in the stream.
+ ///
+ /// Indent the current line using the current indentation level and
+ /// print an optional string following the indentation spaces.
+ ///
+ /// @param[in] s
+ /// A C string to print following the indentation. If nullptr, just
+ /// output the indentation characters.
+ //------------------------------------------------------------------
+ size_t Indent(const char *s = nullptr);
+
+ //------------------------------------------------------------------
+ /// Decrement the current indentation level.
+ //------------------------------------------------------------------
+ void IndentLess(int amount = 2);
+
+ //------------------------------------------------------------------
+ /// Increment the current indentation level.
+ //------------------------------------------------------------------
+ void IndentMore(int amount = 2);
+
+ //------------------------------------------------------------------
+ /// Output an offset value.
+ ///
+ /// Put an offset \a uval out to the stream using the printf format
+ /// in \a format.
+ ///
+ /// @param[in] offset
+ /// The offset value.
+ ///
+ /// @param[in] format
+ /// The printf style format to use when outputting the offset.
+ //------------------------------------------------------------------
+ void Offset(uint32_t offset, const char *format = "0x%8.8x: ");
+
+ //------------------------------------------------------------------
+ /// Output printf formatted output to the stream.
+ ///
+ /// Print some formatted output to the stream.
+ ///
+ /// @param[in] format
+ /// A printf style format string.
+ ///
+ /// @param[in] ...
+ /// Variable arguments that are needed for the printf style
+ /// format string \a format.
+ //------------------------------------------------------------------
+ size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+
+ size_t PrintfVarArg(const char *format, va_list args);
+
+ //------------------------------------------------------------------
+ /// Output a quoted C string value to the stream.
+ ///
+ /// Print a double quoted NULL terminated C string to the stream
+ /// using the printf format in \a format.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminated C string value.
+ ///
+ /// @param[in] format
+ /// The optional C string format that can be overridden.
+ //------------------------------------------------------------------
+ void QuotedCString(const char *cstr, const char *format = "\"%s\"");
+
+ //------------------------------------------------------------------
+ /// Set the address size in bytes.
+ ///
+ /// @param[in] addr_size
+ /// The new size in bytes of an address to use when outputting
+ /// address and pointer values.
+ //------------------------------------------------------------------
+ void SetAddressByteSize(uint32_t addr_size);
+
+ //------------------------------------------------------------------
+ /// Set the current indentation level.
+ ///
+ /// @param[in] level
+ /// The new indentation level.
+ //------------------------------------------------------------------
+ void SetIndentLevel(int level);
+
+ //------------------------------------------------------------------
+ /// Output a SLEB128 number to the stream.
+ ///
+ /// Put an SLEB128 \a uval out to the stream using the printf format
+ /// in \a format.
+ ///
+ /// @param[in] uval
+ /// A uint64_t value that was extracted as a SLEB128 value.
+ ///
+ /// @param[in] format
+ /// The optional printf format that can be overridden.
+ //------------------------------------------------------------------
+ size_t PutSLEB128(int64_t uval);
+
+ //------------------------------------------------------------------
+ /// Output a ULEB128 number to the stream.
+ ///
+ /// Put an ULEB128 \a uval out to the stream using the printf format
+ /// in \a format.
+ ///
+ /// @param[in] uval
+ /// A uint64_t value that was extracted as a ULEB128 value.
+ ///
+ /// @param[in] format
+ /// The optional printf format that can be overridden.
+ //------------------------------------------------------------------
+ size_t PutULEB128(uint64_t uval);
- static void
- UnitTest(Stream *s);
+ static void UnitTest(Stream *s);
protected:
- //------------------------------------------------------------------
- // Member variables
- //------------------------------------------------------------------
- Flags m_flags; ///< Dump flags.
- uint32_t m_addr_size; ///< Size of an address in bytes.
- lldb::ByteOrder m_byte_order; ///< Byte order to use when encoding scalar types.
- int m_indent_level; ///< Indention level.
+ //------------------------------------------------------------------
+ // Member variables
+ //------------------------------------------------------------------
+ Flags m_flags; ///< Dump flags.
+ uint32_t m_addr_size; ///< Size of an address in bytes.
+ lldb::ByteOrder
+ m_byte_order; ///< Byte order to use when encoding scalar types.
+ int m_indent_level; ///< Indention level.
- size_t _PutHex8 (uint8_t uvalue, bool add_prefix);
+ size_t _PutHex8(uint8_t uvalue, bool add_prefix);
};
} // namespace lldb_private
-#endif // liblldb_Stream_h_
+#endif // liblldb_Stream_h_
Modified: lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h (original)
+++ lldb/trunk/include/lldb/Core/StreamAsynchronousIO.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- StreamAsynchronousIO.h -----------------------------------*- C++ -*-===//
+//===-- StreamAsynchronousIO.h -----------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,24 +17,20 @@
namespace lldb_private {
-class StreamAsynchronousIO :
- public Stream
-{
+class StreamAsynchronousIO : public Stream {
public:
- StreamAsynchronousIO (Debugger &debugger, bool for_stdout);
-
- ~StreamAsynchronousIO () override;
-
- void
- Flush () override;
-
- size_t
- Write (const void *src, size_t src_len) override;
-
+ StreamAsynchronousIO(Debugger &debugger, bool for_stdout);
+
+ ~StreamAsynchronousIO() override;
+
+ void Flush() override;
+
+ size_t Write(const void *src, size_t src_len) override;
+
private:
- Debugger &m_debugger;
- std::string m_data;
- bool m_for_stdout;
+ Debugger &m_debugger;
+ std::string m_data;
+ bool m_for_stdout;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StreamBuffer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamBuffer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamBuffer.h (original)
+++ lldb/trunk/include/lldb/Core/StreamBuffer.h Tue Sep 6 15:57:50 2016
@@ -10,78 +10,47 @@
#ifndef liblldb_StreamBuffer_h_
#define liblldb_StreamBuffer_h_
+#include "lldb/Core/Stream.h"
+#include "llvm/ADT/SmallVector.h"
#include <stdio.h>
#include <string>
-#include "llvm/ADT/SmallVector.h"
-#include "lldb/Core/Stream.h"
namespace lldb_private {
-template <unsigned N>
-class StreamBuffer : public Stream
-{
+template <unsigned N> class StreamBuffer : public Stream {
public:
- StreamBuffer () :
- Stream (0, 4, lldb::eByteOrderBig),
- m_packet ()
- {
- }
-
-
- StreamBuffer (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order) :
- Stream (flags, addr_size, byte_order),
- m_packet ()
- {
- }
-
- virtual
- ~StreamBuffer ()
- {
- }
-
- virtual void
- Flush ()
- {
- // Nothing to do when flushing a buffer based stream...
- }
-
- virtual size_t
- Write (const void *s, size_t length)
- {
- if (s && length)
- m_packet.append ((const char *)s, ((const char *)s) + length);
- return length;
- }
-
- void
- Clear()
- {
- m_packet.clear();
- }
-
- // Beware, this might not be NULL terminated as you can expect from
- // StringString as there may be random bits in the llvm::SmallVector. If
- // you are using this class to create a C string, be sure the call PutChar ('\0')
- // after you have created your string, or use StreamString.
- const char *
- GetData () const
- {
- return m_packet.data();
- }
-
- size_t
- GetSize() const
- {
- return m_packet.size();
- }
+ StreamBuffer() : Stream(0, 4, lldb::eByteOrderBig), m_packet() {}
-protected:
- llvm::SmallVector<char, N> m_packet;
+ StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order)
+ : Stream(flags, addr_size, byte_order), m_packet() {}
+
+ virtual ~StreamBuffer() {}
+ virtual void Flush() {
+ // Nothing to do when flushing a buffer based stream...
+ }
+
+ virtual size_t Write(const void *s, size_t length) {
+ if (s && length)
+ m_packet.append((const char *)s, ((const char *)s) + length);
+ return length;
+ }
+
+ void Clear() { m_packet.clear(); }
+
+ // Beware, this might not be NULL terminated as you can expect from
+ // StringString as there may be random bits in the llvm::SmallVector. If
+ // you are using this class to create a C string, be sure the call PutChar
+ // ('\0')
+ // after you have created your string, or use StreamString.
+ const char *GetData() const { return m_packet.data(); }
+
+ size_t GetSize() const { return m_packet.size(); }
+
+protected:
+ llvm::SmallVector<char, N> m_packet;
};
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamBuffer_h_
+#endif // #ifndef liblldb_StreamBuffer_h_
Modified: lldb/trunk/include/lldb/Core/StreamCallback.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamCallback.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamCallback.h (original)
+++ lldb/trunk/include/lldb/Core/StreamCallback.h Tue Sep 6 15:57:50 2016
@@ -18,28 +18,24 @@
namespace lldb_private {
-class StreamCallback :
- public Stream
-{
+class StreamCallback : public Stream {
public:
- StreamCallback (lldb::LogOutputCallback callback, void *baton);
-
- ~StreamCallback () override;
-
- void
- Flush () override;
-
- size_t
- Write (const void *src, size_t src_len) override;
-
+ StreamCallback(lldb::LogOutputCallback callback, void *baton);
+
+ ~StreamCallback() override;
+
+ void Flush() override;
+
+ size_t Write(const void *src, size_t src_len) override;
+
private:
- typedef std::map<lldb::tid_t, StreamString> collection;
- lldb::LogOutputCallback m_callback;
- void *m_baton;
- collection m_accumulated_data;
- std::mutex m_collection_mutex;
+ typedef std::map<lldb::tid_t, StreamString> collection;
+ lldb::LogOutputCallback m_callback;
+ void *m_baton;
+ collection m_accumulated_data;
+ std::mutex m_collection_mutex;
- StreamString &FindStreamForThread(lldb::tid_t cur_tid);
+ StreamString &FindStreamForThread(lldb::tid_t cur_tid);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StreamFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamFile.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamFile.h (original)
+++ lldb/trunk/include/lldb/Core/StreamFile.h Tue Sep 6 15:57:50 2016
@@ -23,54 +23,42 @@
namespace lldb_private {
-class StreamFile : public Stream
-{
+class StreamFile : public Stream {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StreamFile ();
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StreamFile();
- StreamFile (uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
+ StreamFile(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
- StreamFile (int fd, bool transfer_ownership);
+ StreamFile(int fd, bool transfer_ownership);
- StreamFile (const char *path);
+ StreamFile(const char *path);
- StreamFile (const char *path,
- uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault);
+ StreamFile(const char *path, uint32_t options,
+ uint32_t permissions = lldb::eFilePermissionsFileDefault);
- StreamFile (FILE *fh, bool transfer_ownership);
+ StreamFile(FILE *fh, bool transfer_ownership);
- ~StreamFile() override;
+ ~StreamFile() override;
- File &
- GetFile ()
- {
- return m_file;
- }
+ File &GetFile() { return m_file; }
- const File &
- GetFile () const
- {
- return m_file;
- }
+ const File &GetFile() const { return m_file; }
- void
- Flush () override;
+ void Flush() override;
- size_t
- Write (const void *s, size_t length) override;
+ size_t Write(const void *s, size_t length) override;
protected:
- //------------------------------------------------------------------
- // Classes that inherit from StreamFile can see and modify these
- //------------------------------------------------------------------
- File m_file;
-
+ //------------------------------------------------------------------
+ // Classes that inherit from StreamFile can see and modify these
+ //------------------------------------------------------------------
+ File m_file;
+
private:
- DISALLOW_COPY_AND_ASSIGN (StreamFile);
+ DISALLOW_COPY_AND_ASSIGN(StreamFile);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StreamGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamGDBRemote.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamGDBRemote.h (original)
+++ lldb/trunk/include/lldb/Core/StreamGDBRemote.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- StreamGDBRemote.h ----------------------------------------*- C++ -*-===//
+//===-- StreamGDBRemote.h ----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,34 +20,30 @@
#include "lldb/Core/StreamString.h"
namespace lldb_private {
-
- class StreamGDBRemote : public StreamString
- {
- public:
- StreamGDBRemote ();
-
- StreamGDBRemote (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order);
-
- ~StreamGDBRemote() override;
-
- //------------------------------------------------------------------
- /// Output a block of data to the stream performing GDB-remote escaping.
- ///
- /// @param[in] s
- /// A block of data.
- ///
- /// @param[in] src_len
- /// The amount of data to write.
- ///
- /// @return
- /// Number of bytes written.
- //------------------------------------------------------------------
- int
- PutEscapedBytes (const void* s,
- size_t src_len);
- };
+
+class StreamGDBRemote : public StreamString {
+public:
+ StreamGDBRemote();
+
+ StreamGDBRemote(uint32_t flags, uint32_t addr_size,
+ lldb::ByteOrder byte_order);
+
+ ~StreamGDBRemote() override;
+
+ //------------------------------------------------------------------
+ /// Output a block of data to the stream performing GDB-remote escaping.
+ ///
+ /// @param[in] s
+ /// A block of data.
+ ///
+ /// @param[in] src_len
+ /// The amount of data to write.
+ ///
+ /// @return
+ /// Number of bytes written.
+ //------------------------------------------------------------------
+ int PutEscapedBytes(const void *s, size_t src_len);
+};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StreamString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamString.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamString.h (original)
+++ lldb/trunk/include/lldb/Core/StreamString.h Tue Sep 6 15:57:50 2016
@@ -16,49 +16,36 @@
namespace lldb_private {
-class StreamString : public Stream
-{
+class StreamString : public Stream {
public:
- StreamString ();
+ StreamString();
- StreamString (uint32_t flags,
- uint32_t addr_size,
- lldb::ByteOrder byte_order);
+ StreamString(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
- ~StreamString () override;
+ ~StreamString() override;
- void
- Flush () override;
+ void Flush() override;
- size_t
- Write (const void *s, size_t length) override;
+ size_t Write(const void *s, size_t length) override;
- void
- Clear();
+ void Clear();
- bool
- Empty() const;
+ bool Empty() const;
- const char *
- GetData () const;
+ const char *GetData() const;
- size_t
- GetSize() const;
+ size_t GetSize() const;
- size_t
- GetSizeOfLastLine () const;
+ size_t GetSizeOfLastLine() const;
- std::string &
- GetString();
+ std::string &GetString();
- const std::string &
- GetString() const;
+ const std::string &GetString() const;
- void
- FillLastLineToColumn (uint32_t column, char fill_char);
+ void FillLastLineToColumn(uint32_t column, char fill_char);
protected:
- std::string m_packet;
+ std::string m_packet;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StreamTee.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamTee.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StreamTee.h (original)
+++ lldb/trunk/include/lldb/Core/StreamTee.h Tue Sep 6 15:57:50 2016
@@ -18,143 +18,122 @@
namespace lldb_private {
-class StreamTee : public Stream
-{
+class StreamTee : public Stream {
public:
- StreamTee() : Stream(), m_streams_mutex(), m_streams() {}
+ StreamTee() : Stream(), m_streams_mutex(), m_streams() {}
- StreamTee(lldb::StreamSP &stream_sp) : Stream(), m_streams_mutex(), m_streams()
- {
- // No need to lock mutex during construction
- if (stream_sp)
- m_streams.push_back(stream_sp);
- }
-
- StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp) : Stream(), m_streams_mutex(), m_streams()
- {
- // No need to lock mutex during construction
- if (stream_sp)
- m_streams.push_back(stream_sp);
- if (stream_2_sp)
- m_streams.push_back(stream_2_sp);
- }
-
- StreamTee(const StreamTee &rhs) : Stream(rhs), m_streams_mutex(), m_streams()
- {
- // Don't copy until we lock down "rhs"
- std::lock_guard<std::recursive_mutex> guard(rhs.m_streams_mutex);
- m_streams = rhs.m_streams;
- }
-
- ~StreamTee () override
- {
- }
-
- StreamTee &
- operator=(const StreamTee &rhs)
- {
- if (this != &rhs)
- {
- Stream::operator=(rhs);
- std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex);
- std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex);
- m_streams = rhs.m_streams;
- }
- return *this;
- }
-
- void
- Flush() override
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- collection::iterator pos, end;
- for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos)
- {
- // Allow for our collection to contain NULL streams. This allows
- // the StreamTee to be used with hard coded indexes for clients
- // that might want N total streams with only a few that are set
- // to valid values.
- Stream *strm = pos->get();
- if (strm)
- strm->Flush();
- }
- }
-
- size_t
- Write(const void *s, size_t length) override
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- if (m_streams.empty())
- return 0;
-
- size_t min_bytes_written = SIZE_MAX;
- collection::iterator pos, end;
- for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos)
- {
- // Allow for our collection to contain NULL streams. This allows
- // the StreamTee to be used with hard coded indexes for clients
- // that might want N total streams with only a few that are set
- // to valid values.
- Stream *strm = pos->get();
- if (strm)
- {
- const size_t bytes_written = strm->Write(s, length);
- if (min_bytes_written > bytes_written)
- min_bytes_written = bytes_written;
- }
- }
- if (min_bytes_written == SIZE_MAX)
- return 0;
- return min_bytes_written;
- }
-
- size_t
- AppendStream(const lldb::StreamSP &stream_sp)
- {
- size_t new_idx = m_streams.size();
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- m_streams.push_back(stream_sp);
- return new_idx;
- }
-
- size_t
- GetNumStreams() const
- {
- size_t result = 0;
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- result = m_streams.size();
- }
- return result;
- }
-
- lldb::StreamSP
- GetStreamAtIndex(uint32_t idx)
- {
- lldb::StreamSP stream_sp;
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- if (idx < m_streams.size())
- stream_sp = m_streams[idx];
- return stream_sp;
- }
-
- void
- SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp)
- {
- std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
- // Resize our stream vector as necessary to fit as many streams
- // as needed. This also allows this class to be used with hard
- // coded indexes that can be used contain many streams, not all
- // of which are valid.
- if (idx >= m_streams.size())
- m_streams.resize(idx + 1);
- m_streams[idx] = stream_sp;
- }
+ StreamTee(lldb::StreamSP &stream_sp)
+ : Stream(), m_streams_mutex(), m_streams() {
+ // No need to lock mutex during construction
+ if (stream_sp)
+ m_streams.push_back(stream_sp);
+ }
+
+ StreamTee(lldb::StreamSP &stream_sp, lldb::StreamSP &stream_2_sp)
+ : Stream(), m_streams_mutex(), m_streams() {
+ // No need to lock mutex during construction
+ if (stream_sp)
+ m_streams.push_back(stream_sp);
+ if (stream_2_sp)
+ m_streams.push_back(stream_2_sp);
+ }
+
+ StreamTee(const StreamTee &rhs)
+ : Stream(rhs), m_streams_mutex(), m_streams() {
+ // Don't copy until we lock down "rhs"
+ std::lock_guard<std::recursive_mutex> guard(rhs.m_streams_mutex);
+ m_streams = rhs.m_streams;
+ }
+
+ ~StreamTee() override {}
+
+ StreamTee &operator=(const StreamTee &rhs) {
+ if (this != &rhs) {
+ Stream::operator=(rhs);
+ std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex);
+ std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex);
+ m_streams = rhs.m_streams;
+ }
+ return *this;
+ }
+
+ void Flush() override {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ collection::iterator pos, end;
+ for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) {
+ // Allow for our collection to contain NULL streams. This allows
+ // the StreamTee to be used with hard coded indexes for clients
+ // that might want N total streams with only a few that are set
+ // to valid values.
+ Stream *strm = pos->get();
+ if (strm)
+ strm->Flush();
+ }
+ }
+
+ size_t Write(const void *s, size_t length) override {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ if (m_streams.empty())
+ return 0;
+
+ size_t min_bytes_written = SIZE_MAX;
+ collection::iterator pos, end;
+ for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) {
+ // Allow for our collection to contain NULL streams. This allows
+ // the StreamTee to be used with hard coded indexes for clients
+ // that might want N total streams with only a few that are set
+ // to valid values.
+ Stream *strm = pos->get();
+ if (strm) {
+ const size_t bytes_written = strm->Write(s, length);
+ if (min_bytes_written > bytes_written)
+ min_bytes_written = bytes_written;
+ }
+ }
+ if (min_bytes_written == SIZE_MAX)
+ return 0;
+ return min_bytes_written;
+ }
+
+ size_t AppendStream(const lldb::StreamSP &stream_sp) {
+ size_t new_idx = m_streams.size();
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ m_streams.push_back(stream_sp);
+ return new_idx;
+ }
+
+ size_t GetNumStreams() const {
+ size_t result = 0;
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ result = m_streams.size();
+ }
+ return result;
+ }
+
+ lldb::StreamSP GetStreamAtIndex(uint32_t idx) {
+ lldb::StreamSP stream_sp;
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ if (idx < m_streams.size())
+ stream_sp = m_streams[idx];
+ return stream_sp;
+ }
+
+ void SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_streams_mutex);
+ // Resize our stream vector as necessary to fit as many streams
+ // as needed. This also allows this class to be used with hard
+ // coded indexes that can be used contain many streams, not all
+ // of which are valid.
+ if (idx >= m_streams.size())
+ m_streams.resize(idx + 1);
+ m_streams[idx] = stream_sp;
+ }
protected:
- typedef std::vector<lldb::StreamSP> collection;
- mutable std::recursive_mutex m_streams_mutex;
- collection m_streams;
+ typedef std::vector<lldb::StreamSP> collection;
+ mutable std::recursive_mutex m_streams_mutex;
+ collection m_streams;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StringList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StringList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StringList.h (original)
+++ lldb/trunk/include/lldb/Core/StringList.h Tue Sep 6 15:57:50 2016
@@ -20,159 +20,120 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/Core/STLUtils.h"
+#include "lldb/lldb-forward.h"
namespace lldb_private {
-class StringList
-{
+class StringList {
public:
- StringList ();
+ StringList();
+
+ StringList(const char *str);
+
+ StringList(const char **strv, int strc);
+
+ virtual ~StringList();
+
+ void AppendString(const std::string &s);
+
+ void AppendString(std::string &&s);
+
+ void AppendString(const char *str);
+
+ void AppendString(const char *str, size_t str_len);
+
+ void AppendString(llvm::StringRef str);
+
+ void AppendList(const char **strv, int strc);
+
+ void AppendList(StringList strings);
+
+ bool ReadFileLines(FileSpec &input_file);
+
+ size_t GetSize() const;
+
+ void SetSize(size_t n) { m_strings.resize(n); }
+
+ size_t GetMaxStringLength() const;
+
+ std::string &operator[](size_t idx) {
+ // No bounds checking, verify "idx" is good prior to calling this function
+ return m_strings[idx];
+ }
+
+ const std::string &operator[](size_t idx) const {
+ // No bounds checking, verify "idx" is good prior to calling this function
+ return m_strings[idx];
+ }
+
+ void PopBack() { m_strings.pop_back(); }
+ const char *GetStringAtIndex(size_t idx) const;
+
+ void Join(const char *separator, Stream &strm);
+
+ void Clear();
+
+ void LongestCommonPrefix(std::string &common_prefix);
+
+ void InsertStringAtIndex(size_t idx, const std::string &str);
+
+ void InsertStringAtIndex(size_t idx, std::string &&str);
+
+ void InsertStringAtIndex(size_t id, const char *str);
+
+ void DeleteStringAtIndex(size_t id);
+
+ void RemoveBlankLines();
+
+ size_t SplitIntoLines(const std::string &lines);
+
+ size_t SplitIntoLines(const char *lines, size_t len);
+
+ std::string CopyList(const char *item_preamble = nullptr,
+ const char *items_sep = "\n") const;
+
+ StringList &operator<<(const char *str);
+
+ StringList &operator<<(const std::string &s);
+
+ StringList &operator<<(StringList strings);
+
+ // Copy assignment for a vector of strings
+ StringList &operator=(const std::vector<std::string> &rhs);
+
+ // This string list contains a list of valid auto completion
+ // strings, and the "s" is passed in. "matches" is filled in
+ // with zero or more string values that start with "s", and
+ // the first string to exactly match one of the string
+ // values in this collection, will have "exact_matches_idx"
+ // filled in to match the index, or "exact_matches_idx" will
+ // have SIZE_MAX
+ size_t AutoComplete(const char *s, StringList &matches,
+ size_t &exact_matches_idx) const;
+
+ // Dump the StringList to the given lldb_private::Log, `log`, one item per
+ // line.
+ // If given, `name` will be used to identify the start and end of the list in
+ // the output.
+ virtual void LogDump(Log *log, const char *name = nullptr);
- StringList (const char *str);
+ // Static helper to convert an iterable of strings to a StringList, and then
+ // dump it with the semantics of the `LogDump` method.
+ template <typename T>
+ static void LogDump(Log *log, T s_iterable, const char *name = nullptr) {
+ if (!log)
+ return;
+ // Make a copy of the iterable as a StringList
+ StringList l{};
+ for (const auto &s : s_iterable)
+ l << s;
- StringList (const char **strv, int strc);
-
- virtual
- ~StringList ();
-
- void
- AppendString (const std::string &s);
-
- void
- AppendString (std::string &&s);
-
- void
- AppendString (const char *str);
-
- void
- AppendString (const char *str, size_t str_len);
-
- void
- AppendString(llvm::StringRef str);
-
- void
- AppendList (const char ** strv, int strc);
-
- void
- AppendList (StringList strings);
-
- bool
- ReadFileLines (FileSpec &input_file);
-
- size_t
- GetSize () const;
-
- void
- SetSize (size_t n)
- {
- m_strings.resize(n);
- }
-
- size_t
- GetMaxStringLength () const;
-
- std::string &
- operator [](size_t idx)
- {
- // No bounds checking, verify "idx" is good prior to calling this function
- return m_strings[idx];
- }
-
- const std::string &
- operator [](size_t idx) const
- {
- // No bounds checking, verify "idx" is good prior to calling this function
- return m_strings[idx];
- }
-
- void
- PopBack ()
- {
- m_strings.pop_back();
- }
- const char *
- GetStringAtIndex (size_t idx) const;
-
- void
- Join (const char *separator, Stream &strm);
-
- void
- Clear ();
-
- void
- LongestCommonPrefix (std::string &common_prefix);
-
- void
- InsertStringAtIndex (size_t idx, const std::string &str);
-
- void
- InsertStringAtIndex (size_t idx, std::string &&str);
-
- void
- InsertStringAtIndex (size_t id, const char *str);
-
- void
- DeleteStringAtIndex (size_t id);
-
- void
- RemoveBlankLines ();
-
- size_t
- SplitIntoLines (const std::string &lines);
-
- size_t
- SplitIntoLines (const char *lines, size_t len);
-
- std::string
- CopyList(const char* item_preamble = nullptr,
- const char* items_sep = "\n") const;
-
- StringList&
- operator << (const char* str);
-
- StringList&
- operator << (const std::string &s);
-
- StringList&
- operator << (StringList strings);
-
- // Copy assignment for a vector of strings
- StringList&
- operator = (const std::vector<std::string> &rhs);
-
- // This string list contains a list of valid auto completion
- // strings, and the "s" is passed in. "matches" is filled in
- // with zero or more string values that start with "s", and
- // the first string to exactly match one of the string
- // values in this collection, will have "exact_matches_idx"
- // filled in to match the index, or "exact_matches_idx" will
- // have SIZE_MAX
- size_t
- AutoComplete (const char *s,
- StringList &matches,
- size_t &exact_matches_idx) const;
-
- // Dump the StringList to the given lldb_private::Log, `log`, one item per line.
- // If given, `name` will be used to identify the start and end of the list in the output.
- virtual void LogDump(Log *log, const char *name = nullptr);
-
- // Static helper to convert an iterable of strings to a StringList, and then
- // dump it with the semantics of the `LogDump` method.
- template<typename T> static void LogDump(Log *log, T s_iterable, const char *name = nullptr)
- {
- if (!log)
- return;
- // Make a copy of the iterable as a StringList
- StringList l{};
- for (const auto &s : s_iterable)
- l << s;
+ l.LogDump(log, name);
+ }
- l.LogDump(log, name);
- }
private:
- STLStringArray m_strings;
+ STLStringArray m_strings;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/StructuredData.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StructuredData.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/StructuredData.h (original)
+++ lldb/trunk/include/lldb/Core/StructuredData.h Tue Sep 6 15:57:50 2016
@@ -23,9 +23,9 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/lldb-defines.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Stream.h"
+#include "lldb/lldb-defines.h"
namespace lldb_private {
@@ -34,725 +34,511 @@ namespace lldb_private {
/// @brief A class which can hold structured data
///
/// The StructuredData class is designed to hold the data from a JSON
-/// or plist style file -- a serialized data structure with dictionaries
-/// (maps, hashes), arrays, and concrete values like integers, floating
+/// or plist style file -- a serialized data structure with dictionaries
+/// (maps, hashes), arrays, and concrete values like integers, floating
/// point numbers, strings, booleans.
///
/// StructuredData does not presuppose any knowledge of the schema for
/// the data it is holding; it can parse JSON data, for instance, and
/// other parts of lldb can iterate through the parsed data set to find
-/// keys and values that may be present.
+/// keys and values that may be present.
//----------------------------------------------------------------------
-class StructuredData
-{
+class StructuredData {
public:
- class Object;
- class Array;
- class Integer;
- class Float;
- class Boolean;
- class String;
- class Dictionary;
- class Generic;
-
- typedef std::shared_ptr<Object> ObjectSP;
- typedef std::shared_ptr<Array> ArraySP;
- typedef std::shared_ptr<Integer> IntegerSP;
- typedef std::shared_ptr<Float> FloatSP;
- typedef std::shared_ptr<Boolean> BooleanSP;
- typedef std::shared_ptr<String> StringSP;
- typedef std::shared_ptr<Dictionary> DictionarySP;
- typedef std::shared_ptr<Generic> GenericSP;
-
- enum class Type
- {
- eTypeInvalid = -1,
- eTypeNull = 0,
- eTypeGeneric,
- eTypeArray,
- eTypeInteger,
- eTypeFloat,
- eTypeBoolean,
- eTypeString,
- eTypeDictionary
- };
-
- class Object :
- public std::enable_shared_from_this<Object>
- {
- public:
-
- Object (Type t = Type::eTypeInvalid) :
- m_type (t)
- {
- }
-
- virtual ~Object() = default;
-
- virtual bool
- IsValid() const
- {
- return true;
- }
-
- virtual void
- Clear ()
- {
- m_type = Type::eTypeInvalid;
- }
-
- Type
- GetType () const
- {
- return m_type;
- }
-
- void
- SetType (Type t)
- {
- m_type = t;
- }
-
- Array *
- GetAsArray ()
- {
- return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this) : nullptr);
- }
-
- Dictionary *
- GetAsDictionary ()
- {
- return ((m_type == Type::eTypeDictionary) ? static_cast<Dictionary *>(this) : nullptr);
- }
-
- Integer *
- GetAsInteger ()
- {
- return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this) : nullptr);
- }
-
- uint64_t
- GetIntegerValue (uint64_t fail_value = 0)
- {
- Integer *integer = GetAsInteger ();
- return ((integer != nullptr) ? integer->GetValue() : fail_value);
- }
-
- Float *
- GetAsFloat ()
- {
- return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this) : nullptr);
- }
-
- double
- GetFloatValue (double fail_value = 0.0)
- {
- Float *f = GetAsFloat ();
- return ((f != nullptr) ? f->GetValue() : fail_value);
- }
-
- Boolean *
- GetAsBoolean ()
- {
- return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this) : nullptr);
- }
-
- bool
- GetBooleanValue (bool fail_value = false)
- {
- Boolean *b = GetAsBoolean ();
- return ((b != nullptr) ? b->GetValue() : fail_value);
- }
-
- String *
- GetAsString ()
- {
- return ((m_type == Type::eTypeString) ? static_cast<String *>(this) : nullptr);
- }
-
- std::string
- GetStringValue(const char *fail_value = nullptr)
- {
- String *s = GetAsString ();
- if (s)
- return s->GetValue();
-
- if (fail_value && fail_value[0])
- return std::string(fail_value);
-
- return std::string();
- }
-
- Generic *
- GetAsGeneric()
- {
- return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this) : nullptr);
- }
-
- ObjectSP
- GetObjectForDotSeparatedPath (llvm::StringRef path);
-
- void DumpToStdout(bool pretty_print = true) const;
-
- virtual void
- Dump (Stream &s, bool pretty_print = true) const = 0;
-
- private:
- Type m_type;
- };
-
- class Array : public Object
- {
- public:
- Array () :
- Object (Type::eTypeArray)
- {
- }
-
- ~Array() override = default;
-
- bool
- ForEach (std::function <bool(Object* object)> const &foreach_callback) const
- {
- for (const auto &object_sp : m_items)
- {
- if (foreach_callback(object_sp.get()) == false)
- return false;
- }
- return true;
- }
-
- size_t
- GetSize() const
- {
- return m_items.size();
- }
-
- ObjectSP
- operator[](size_t idx)
- {
- if (idx < m_items.size())
- return m_items[idx];
- return ObjectSP();
- }
-
- ObjectSP
- GetItemAtIndex(size_t idx) const
- {
- assert(idx < GetSize());
- if (idx < m_items.size())
- return m_items[idx];
- return ObjectSP();
- }
-
- template <class IntType>
- bool
- GetItemAtIndexAsInteger(size_t idx, IntType &result) const
- {
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- if (auto int_value = value_sp->GetAsInteger())
- {
- result = static_cast<IntType>(int_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- template <class IntType>
- bool
- GetItemAtIndexAsInteger(size_t idx, IntType &result, IntType default_val) const
- {
- bool success = GetItemAtIndexAsInteger(idx, result);
- if (!success)
- result = default_val;
- return success;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, std::string &result) const
- {
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- if (auto string_value = value_sp->GetAsString())
- {
- result = string_value->GetValue();
- return true;
- }
- }
- return false;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, std::string &result, const std::string &default_val) const
- {
- bool success = GetItemAtIndexAsString(idx, result);
- if (!success)
- result = default_val;
- return success;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, ConstString &result) const
- {
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get()) {
- if (auto string_value = value_sp->GetAsString())
- {
- result = ConstString(string_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- bool
- GetItemAtIndexAsString(size_t idx, ConstString &result, const char *default_val) const
- {
- bool success = GetItemAtIndexAsString(idx, result);
- if (!success)
- result.SetCString(default_val);
- return success;
- }
-
- bool
- GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- result = value_sp->GetAsDictionary();
- return (result != nullptr);
- }
- return false;
- }
-
- bool
- GetItemAtIndexAsArray(size_t idx, Array *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetItemAtIndex(idx);
- if (value_sp.get())
- {
- result = value_sp->GetAsArray();
- return (result != nullptr);
- }
- return false;
- }
-
- void
- Push(ObjectSP item)
- {
- m_items.push_back(item);
- }
-
- void
- AddItem(ObjectSP item)
- {
- m_items.push_back(item);
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- protected:
- typedef std::vector<ObjectSP> collection;
- collection m_items;
- };
-
- class Integer : public Object
- {
- public:
- Integer (uint64_t i = 0) :
- Object (Type::eTypeInteger),
- m_value (i)
- {
- }
-
- ~Integer() override = default;
-
- void
- SetValue (uint64_t value)
- {
- m_value = value;
- }
-
- uint64_t
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- protected:
- uint64_t m_value;
- };
-
- class Float : public Object
- {
- public:
- Float (double d = 0.0) :
- Object (Type::eTypeFloat),
- m_value (d)
- {
- }
-
- ~Float() override = default;
-
- void
- SetValue (double value)
- {
- m_value = value;
- }
-
- double
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- protected:
- double m_value;
- };
-
- class Boolean : public Object
- {
- public:
- Boolean (bool b = false) :
- Object (Type::eTypeBoolean),
- m_value (b)
- {
- }
-
- ~Boolean() override = default;
-
- void
- SetValue (bool value)
- {
- m_value = value;
- }
-
- bool
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- protected:
- bool m_value;
- };
-
- class String : public Object
- {
- public:
- String(const char *cstr = nullptr) :
- Object (Type::eTypeString),
- m_value ()
- {
- if (cstr)
- m_value = cstr;
- }
-
- String (const std::string &s) :
- Object (Type::eTypeString),
- m_value (s)
- {
- }
-
- String (const std::string &&s) :
- Object (Type::eTypeString),
- m_value (s)
- {
- }
-
- void
- SetValue (const std::string &string)
- {
- m_value = string;
- }
-
- const std::string &
- GetValue ()
- {
- return m_value;
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- protected:
- std::string m_value;
- };
-
- class Dictionary : public Object
- {
- public:
-
- Dictionary () :
- Object (Type::eTypeDictionary),
- m_dict ()
- {
- }
-
- ~Dictionary() override = default;
-
- size_t
- GetSize() const
- {
- return m_dict.size();
- }
-
- void
- ForEach (std::function <bool(ConstString key, Object* object)> const &callback) const
- {
- for (const auto &pair : m_dict)
- {
- if (callback (pair.first, pair.second.get()) == false)
- break;
- }
- }
-
- ObjectSP
- GetKeys() const
- {
- ObjectSP object_sp(new Array ());
- Array *array = object_sp->GetAsArray();
- collection::const_iterator iter;
- for (iter = m_dict.begin(); iter != m_dict.end(); ++iter)
- {
- ObjectSP key_object_sp(new String());
- key_object_sp->GetAsString()->SetValue(iter->first.AsCString());
- array->Push(key_object_sp);
- }
- return object_sp;
- }
-
- ObjectSP
- GetValueForKey(llvm::StringRef key) const
- {
- ObjectSP value_sp;
- if (!key.empty())
- {
- ConstString key_cs(key);
- collection::const_iterator iter = m_dict.find(key_cs);
- if (iter != m_dict.end())
- value_sp = iter->second;
- }
- return value_sp;
- }
-
- template <class IntType>
- bool
- GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
- {
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp) {
- if (auto int_value = value_sp->GetAsInteger())
- {
- result = static_cast<IntType>(int_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- template <class IntType>
- bool
- GetValueForKeyAsInteger(llvm::StringRef key, IntType &result, IntType default_val) const
- {
- bool success = GetValueForKeyAsInteger<IntType>(key, result);
- if (!success)
- result = default_val;
- return success;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, std::string &result) const
- {
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- if (auto string_value = value_sp->GetAsString())
- {
- result = string_value->GetValue();
- return true;
- }
- }
- return false;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, std::string &result, const char *default_val) const
- {
- bool success = GetValueForKeyAsString(key, result);
- if (!success)
- {
- if (default_val)
- result = default_val;
- else
- result.clear();
- }
- return success;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, ConstString &result) const
- {
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- if (auto string_value = value_sp->GetAsString())
- {
- result = ConstString(string_value->GetValue());
- return true;
- }
- }
- return false;
- }
-
- bool
- GetValueForKeyAsString(llvm::StringRef key, ConstString &result, const char *default_val) const
- {
- bool success = GetValueForKeyAsString(key, result);
- if (!success)
- result.SetCString(default_val);
- return success;
- }
-
- bool
- GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- result = value_sp->GetAsDictionary();
- return (result != nullptr);
- }
- return false;
- }
-
- bool
- GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
- {
- result = nullptr;
- ObjectSP value_sp = GetValueForKey(key);
- if (value_sp.get())
- {
- result = value_sp->GetAsArray();
- return (result != nullptr);
- }
- return false;
- }
-
- bool
- HasKey(llvm::StringRef key) const
- {
- ConstString key_cs(key);
- collection::const_iterator search = m_dict.find(key_cs);
- return search != m_dict.end();
- }
-
- void
- AddItem (llvm::StringRef key, ObjectSP value_sp)
- {
- ConstString key_cs(key);
- m_dict[key_cs] = value_sp;
- }
-
- void
- AddIntegerItem (llvm::StringRef key, uint64_t value)
- {
- AddItem (key, ObjectSP (new Integer(value)));
- }
-
- void
- AddFloatItem (llvm::StringRef key, double value)
- {
- AddItem (key, ObjectSP (new Float(value)));
- }
-
- void
- AddStringItem (llvm::StringRef key, std::string value)
- {
- AddItem (key, ObjectSP (new String(std::move(value))));
- }
-
- void
- AddBooleanItem (llvm::StringRef key, bool value)
- {
- AddItem (key, ObjectSP (new Boolean(value)));
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- protected:
- typedef std::map<ConstString, ObjectSP> collection;
- collection m_dict;
- };
-
- class Null : public Object
- {
- public:
- Null () :
- Object (Type::eTypeNull)
- {
- }
-
- ~Null() override = default;
-
- bool
- IsValid() const override
- {
- return false;
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
- };
-
- class Generic : public Object
- {
- public:
- explicit Generic(void *object = nullptr) :
- Object (Type::eTypeGeneric),
- m_object (object)
- {
- }
-
- void
- SetValue(void *value)
- {
- m_object = value;
- }
-
- void *
- GetValue() const
- {
- return m_object;
- }
-
- bool
- IsValid() const override
- {
- return m_object != nullptr;
- }
-
- void Dump(Stream &s, bool pretty_print = true) const override;
-
- private:
- void *m_object;
- };
+ class Object;
+ class Array;
+ class Integer;
+ class Float;
+ class Boolean;
+ class String;
+ class Dictionary;
+ class Generic;
+
+ typedef std::shared_ptr<Object> ObjectSP;
+ typedef std::shared_ptr<Array> ArraySP;
+ typedef std::shared_ptr<Integer> IntegerSP;
+ typedef std::shared_ptr<Float> FloatSP;
+ typedef std::shared_ptr<Boolean> BooleanSP;
+ typedef std::shared_ptr<String> StringSP;
+ typedef std::shared_ptr<Dictionary> DictionarySP;
+ typedef std::shared_ptr<Generic> GenericSP;
+
+ enum class Type {
+ eTypeInvalid = -1,
+ eTypeNull = 0,
+ eTypeGeneric,
+ eTypeArray,
+ eTypeInteger,
+ eTypeFloat,
+ eTypeBoolean,
+ eTypeString,
+ eTypeDictionary
+ };
+
+ class Object : public std::enable_shared_from_this<Object> {
+ public:
+ Object(Type t = Type::eTypeInvalid) : m_type(t) {}
+
+ virtual ~Object() = default;
+
+ virtual bool IsValid() const { return true; }
+
+ virtual void Clear() { m_type = Type::eTypeInvalid; }
+
+ Type GetType() const { return m_type; }
+
+ void SetType(Type t) { m_type = t; }
+
+ Array *GetAsArray() {
+ return ((m_type == Type::eTypeArray) ? static_cast<Array *>(this)
+ : nullptr);
+ }
+
+ Dictionary *GetAsDictionary() {
+ return ((m_type == Type::eTypeDictionary)
+ ? static_cast<Dictionary *>(this)
+ : nullptr);
+ }
+
+ Integer *GetAsInteger() {
+ return ((m_type == Type::eTypeInteger) ? static_cast<Integer *>(this)
+ : nullptr);
+ }
+
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) {
+ Integer *integer = GetAsInteger();
+ return ((integer != nullptr) ? integer->GetValue() : fail_value);
+ }
+
+ Float *GetAsFloat() {
+ return ((m_type == Type::eTypeFloat) ? static_cast<Float *>(this)
+ : nullptr);
+ }
+
+ double GetFloatValue(double fail_value = 0.0) {
+ Float *f = GetAsFloat();
+ return ((f != nullptr) ? f->GetValue() : fail_value);
+ }
+
+ Boolean *GetAsBoolean() {
+ return ((m_type == Type::eTypeBoolean) ? static_cast<Boolean *>(this)
+ : nullptr);
+ }
+
+ bool GetBooleanValue(bool fail_value = false) {
+ Boolean *b = GetAsBoolean();
+ return ((b != nullptr) ? b->GetValue() : fail_value);
+ }
+
+ String *GetAsString() {
+ return ((m_type == Type::eTypeString) ? static_cast<String *>(this)
+ : nullptr);
+ }
+
+ std::string GetStringValue(const char *fail_value = nullptr) {
+ String *s = GetAsString();
+ if (s)
+ return s->GetValue();
+
+ if (fail_value && fail_value[0])
+ return std::string(fail_value);
+
+ return std::string();
+ }
+
+ Generic *GetAsGeneric() {
+ return ((m_type == Type::eTypeGeneric) ? static_cast<Generic *>(this)
+ : nullptr);
+ }
+
+ ObjectSP GetObjectForDotSeparatedPath(llvm::StringRef path);
+
+ void DumpToStdout(bool pretty_print = true) const;
+
+ virtual void Dump(Stream &s, bool pretty_print = true) const = 0;
+
+ private:
+ Type m_type;
+ };
+
+ class Array : public Object {
+ public:
+ Array() : Object(Type::eTypeArray) {}
+
+ ~Array() override = default;
+
+ bool
+ ForEach(std::function<bool(Object *object)> const &foreach_callback) const {
+ for (const auto &object_sp : m_items) {
+ if (foreach_callback(object_sp.get()) == false)
+ return false;
+ }
+ return true;
+ }
+
+ size_t GetSize() const { return m_items.size(); }
+
+ ObjectSP operator[](size_t idx) {
+ if (idx < m_items.size())
+ return m_items[idx];
+ return ObjectSP();
+ }
+
+ ObjectSP GetItemAtIndex(size_t idx) const {
+ assert(idx < GetSize());
+ if (idx < m_items.size())
+ return m_items[idx];
+ return ObjectSP();
+ }
+
+ template <class IntType>
+ bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const {
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto int_value = value_sp->GetAsInteger()) {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <class IntType>
+ bool GetItemAtIndexAsInteger(size_t idx, IntType &result,
+ IntType default_val) const {
+ bool success = GetItemAtIndexAsInteger(idx, result);
+ if (!success)
+ result = default_val;
+ return success;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, std::string &result) const {
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = string_value->GetValue();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, std::string &result,
+ const std::string &default_val) const {
+ bool success = GetItemAtIndexAsString(idx, result);
+ if (!success)
+ result = default_val;
+ return success;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, ConstString &result) const {
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetItemAtIndexAsString(size_t idx, ConstString &result,
+ const char *default_val) const {
+ bool success = GetItemAtIndexAsString(idx, result);
+ if (!success)
+ result.SetCString(default_val);
+ return success;
+ }
+
+ bool GetItemAtIndexAsDictionary(size_t idx, Dictionary *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ bool GetItemAtIndexAsArray(size_t idx, Array *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetItemAtIndex(idx);
+ if (value_sp.get()) {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ void Push(ObjectSP item) { m_items.push_back(item); }
+
+ void AddItem(ObjectSP item) { m_items.push_back(item); }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ typedef std::vector<ObjectSP> collection;
+ collection m_items;
+ };
+
+ class Integer : public Object {
+ public:
+ Integer(uint64_t i = 0) : Object(Type::eTypeInteger), m_value(i) {}
+
+ ~Integer() override = default;
+
+ void SetValue(uint64_t value) { m_value = value; }
+
+ uint64_t GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ uint64_t m_value;
+ };
+
+ class Float : public Object {
+ public:
+ Float(double d = 0.0) : Object(Type::eTypeFloat), m_value(d) {}
+
+ ~Float() override = default;
+
+ void SetValue(double value) { m_value = value; }
+
+ double GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ double m_value;
+ };
+
+ class Boolean : public Object {
+ public:
+ Boolean(bool b = false) : Object(Type::eTypeBoolean), m_value(b) {}
+
+ ~Boolean() override = default;
+
+ void SetValue(bool value) { m_value = value; }
+
+ bool GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ bool m_value;
+ };
+
+ class String : public Object {
+ public:
+ String(const char *cstr = nullptr) : Object(Type::eTypeString), m_value() {
+ if (cstr)
+ m_value = cstr;
+ }
+
+ String(const std::string &s) : Object(Type::eTypeString), m_value(s) {}
+
+ String(const std::string &&s) : Object(Type::eTypeString), m_value(s) {}
+
+ void SetValue(const std::string &string) { m_value = string; }
+
+ const std::string &GetValue() { return m_value; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ std::string m_value;
+ };
+
+ class Dictionary : public Object {
+ public:
+ Dictionary() : Object(Type::eTypeDictionary), m_dict() {}
+
+ ~Dictionary() override = default;
+
+ size_t GetSize() const { return m_dict.size(); }
+
+ void ForEach(std::function<bool(ConstString key, Object *object)> const
+ &callback) const {
+ for (const auto &pair : m_dict) {
+ if (callback(pair.first, pair.second.get()) == false)
+ break;
+ }
+ }
+
+ ObjectSP GetKeys() const {
+ ObjectSP object_sp(new Array());
+ Array *array = object_sp->GetAsArray();
+ collection::const_iterator iter;
+ for (iter = m_dict.begin(); iter != m_dict.end(); ++iter) {
+ ObjectSP key_object_sp(new String());
+ key_object_sp->GetAsString()->SetValue(iter->first.AsCString());
+ array->Push(key_object_sp);
+ }
+ return object_sp;
+ }
+
+ ObjectSP GetValueForKey(llvm::StringRef key) const {
+ ObjectSP value_sp;
+ if (!key.empty()) {
+ ConstString key_cs(key);
+ collection::const_iterator iter = m_dict.find(key_cs);
+ if (iter != m_dict.end())
+ value_sp = iter->second;
+ }
+ return value_sp;
+ }
+
+ template <class IntType>
+ bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const {
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp) {
+ if (auto int_value = value_sp->GetAsInteger()) {
+ result = static_cast<IntType>(int_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <class IntType>
+ bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result,
+ IntType default_val) const {
+ bool success = GetValueForKeyAsInteger<IntType>(key, result);
+ if (!success)
+ result = default_val;
+ return success;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key,
+ std::string &result) const {
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = string_value->GetValue();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key, std::string &result,
+ const char *default_val) const {
+ bool success = GetValueForKeyAsString(key, result);
+ if (!success) {
+ if (default_val)
+ result = default_val;
+ else
+ result.clear();
+ }
+ return success;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key,
+ ConstString &result) const {
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ if (auto string_value = value_sp->GetAsString()) {
+ result = ConstString(string_value->GetValue());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool GetValueForKeyAsString(llvm::StringRef key, ConstString &result,
+ const char *default_val) const {
+ bool success = GetValueForKeyAsString(key, result);
+ if (!success)
+ result.SetCString(default_val);
+ return success;
+ }
+
+ bool GetValueForKeyAsDictionary(llvm::StringRef key,
+ Dictionary *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ result = value_sp->GetAsDictionary();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const {
+ result = nullptr;
+ ObjectSP value_sp = GetValueForKey(key);
+ if (value_sp.get()) {
+ result = value_sp->GetAsArray();
+ return (result != nullptr);
+ }
+ return false;
+ }
+
+ bool HasKey(llvm::StringRef key) const {
+ ConstString key_cs(key);
+ collection::const_iterator search = m_dict.find(key_cs);
+ return search != m_dict.end();
+ }
+
+ void AddItem(llvm::StringRef key, ObjectSP value_sp) {
+ ConstString key_cs(key);
+ m_dict[key_cs] = value_sp;
+ }
+
+ void AddIntegerItem(llvm::StringRef key, uint64_t value) {
+ AddItem(key, ObjectSP(new Integer(value)));
+ }
+
+ void AddFloatItem(llvm::StringRef key, double value) {
+ AddItem(key, ObjectSP(new Float(value)));
+ }
+
+ void AddStringItem(llvm::StringRef key, std::string value) {
+ AddItem(key, ObjectSP(new String(std::move(value))));
+ }
+
+ void AddBooleanItem(llvm::StringRef key, bool value) {
+ AddItem(key, ObjectSP(new Boolean(value)));
+ }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ protected:
+ typedef std::map<ConstString, ObjectSP> collection;
+ collection m_dict;
+ };
+
+ class Null : public Object {
+ public:
+ Null() : Object(Type::eTypeNull) {}
+
+ ~Null() override = default;
+
+ bool IsValid() const override { return false; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+ };
+
+ class Generic : public Object {
+ public:
+ explicit Generic(void *object = nullptr)
+ : Object(Type::eTypeGeneric), m_object(object) {}
+
+ void SetValue(void *value) { m_object = value; }
+
+ void *GetValue() const { return m_object; }
+
+ bool IsValid() const override { return m_object != nullptr; }
+
+ void Dump(Stream &s, bool pretty_print = true) const override;
+
+ private:
+ void *m_object;
+ };
- static ObjectSP
- ParseJSON (std::string json_text);
+ static ObjectSP ParseJSON(std::string json_text);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h (original)
+++ lldb/trunk/include/lldb/Core/ThreadSafeDenseMap.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ThreadSafeDenseMap.h ------------------------------------------*- C++ -*-===//
+//===-- ThreadSafeDenseMap.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -20,61 +21,50 @@
// Project includes
namespace lldb_private {
-
-template <typename _KeyType, typename _ValueType, typename _MutexType = std::mutex>
-class ThreadSafeDenseMap
-{
+
+template <typename _KeyType, typename _ValueType,
+ typename _MutexType = std::mutex>
+class ThreadSafeDenseMap {
public:
- typedef llvm::DenseMap<_KeyType,_ValueType> LLVMMapType;
+ typedef llvm::DenseMap<_KeyType, _ValueType> LLVMMapType;
- ThreadSafeDenseMap(unsigned map_initial_capacity = 0) : m_map(map_initial_capacity), m_mutex() {}
+ ThreadSafeDenseMap(unsigned map_initial_capacity = 0)
+ : m_map(map_initial_capacity), m_mutex() {}
- void
- Insert (_KeyType k, _ValueType v)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- m_map.insert(std::make_pair(k,v));
- }
-
- void
- Erase (_KeyType k)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- m_map.erase(k);
- }
-
- _ValueType
- Lookup (_KeyType k)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- return m_map.lookup(k);
- }
-
- bool
- Lookup (_KeyType k,
- _ValueType& v)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- auto iter = m_map.find(k),
- end = m_map.end();
- if (iter == end)
- return false;
- v = iter->second;
- return true;
- }
-
- void
- Clear ()
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- m_map.clear();
- }
+ void Insert(_KeyType k, _ValueType v) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_map.insert(std::make_pair(k, v));
+ }
+
+ void Erase(_KeyType k) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_map.erase(k);
+ }
+
+ _ValueType Lookup(_KeyType k) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ return m_map.lookup(k);
+ }
+
+ bool Lookup(_KeyType k, _ValueType &v) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ auto iter = m_map.find(k), end = m_map.end();
+ if (iter == end)
+ return false;
+ v = iter->second;
+ return true;
+ }
+
+ void Clear() {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_map.clear();
+ }
protected:
- LLVMMapType m_map;
- _MutexType m_mutex;
+ LLVMMapType m_map;
+ _MutexType m_mutex;
};
} // namespace lldb_private
-#endif // liblldb_ThreadSafeSTLMap_h_
+#endif // liblldb_ThreadSafeSTLMap_h_
Modified: lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h (original)
+++ lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ThreadSafeDenseSet.h ------------------------------------------*- C++ -*-===//
+//===-- ThreadSafeDenseSet.h ------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,46 +23,38 @@
namespace lldb_private {
template <typename _ElementType, typename _MutexType = std::mutex>
-class ThreadSafeDenseSet
-{
+class ThreadSafeDenseSet {
public:
- typedef llvm::DenseSet<_ElementType> LLVMSetType;
+ typedef llvm::DenseSet<_ElementType> LLVMSetType;
- ThreadSafeDenseSet(unsigned set_initial_capacity = 0) : m_set(set_initial_capacity), m_mutex() {}
+ ThreadSafeDenseSet(unsigned set_initial_capacity = 0)
+ : m_set(set_initial_capacity), m_mutex() {}
- void
- Insert(_ElementType e)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- m_set.insert(e);
- }
-
- void
- Erase(_ElementType e)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- m_set.erase(e);
- }
-
- bool
- Lookup(_ElementType e)
- {
- std::lock_guard<_MutexType> guard(m_mutex);
- return (m_set.count(e) > 0);
- }
-
- void
- Clear()
- {
- stds::lock_guard<_MutexType> guard(m_mutex);
- m_set.clear();
- }
+ void Insert(_ElementType e) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_set.insert(e);
+ }
+
+ void Erase(_ElementType e) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ m_set.erase(e);
+ }
+
+ bool Lookup(_ElementType e) {
+ std::lock_guard<_MutexType> guard(m_mutex);
+ return (m_set.count(e) > 0);
+ }
+
+ void Clear() {
+ stds::lock_guard<_MutexType> guard(m_mutex);
+ m_set.clear();
+ }
protected:
- LLVMSetType m_set;
- _MutexType m_mutex;
+ LLVMSetType m_set;
+ _MutexType m_mutex;
};
} // namespace lldb_private
-#endif // liblldb_ThreadSafeDenseSet_h_
+#endif // liblldb_ThreadSafeDenseSet_h_
Modified: lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h (original)
+++ lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h Tue Sep 6 15:57:50 2016
@@ -21,158 +21,117 @@
namespace lldb_private {
-template <typename _Key, typename _Tp>
-class ThreadSafeSTLMap
-{
+template <typename _Key, typename _Tp> class ThreadSafeSTLMap {
public:
- typedef std::map<_Key,_Tp> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeSTLMap() : m_collection(), m_mutex() {}
+ typedef std::map<_Key, _Tp> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeSTLMap() : m_collection(), m_mutex() {}
+
+ ~ThreadSafeSTLMap() {}
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.empty();
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.clear();
+ }
+
+ size_t Erase(const _Key &key) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return EraseNoLock(key);
+ }
+
+ size_t EraseNoLock(const _Key &key) { return m_collection.erase(key); }
+
+ bool GetValueForKey(const _Key &key, _Tp &value) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return GetValueForKeyNoLock(key, value);
+ }
+
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ bool GetValueForKeyNoLock(const _Key &key, _Tp &value) const {
+ const_iterator pos = m_collection.find(key);
+ if (pos != m_collection.end()) {
+ value = pos->second;
+ return true;
+ }
+ return false;
+ }
+
+ bool GetFirstKeyForValue(const _Tp &value, _Key &key) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return GetFirstKeyForValueNoLock(value, key);
+ }
+
+ bool GetFirstKeyForValueNoLock(const _Tp &value, _Key &key) const {
+ const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.begin(); pos != end; ++pos) {
+ if (pos->second == value) {
+ key = pos->first;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool LowerBound(const _Key &key, _Key &match_key, _Tp &match_value,
+ bool decrement_if_not_equal) const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return LowerBoundNoLock(key, match_key, match_value,
+ decrement_if_not_equal);
+ }
+
+ bool LowerBoundNoLock(const _Key &key, _Key &match_key, _Tp &match_value,
+ bool decrement_if_not_equal) const {
+ const_iterator pos = m_collection.lower_bound(key);
+ if (pos != m_collection.end()) {
+ match_key = pos->first;
+ if (decrement_if_not_equal && key != match_key &&
+ pos != m_collection.begin()) {
+ --pos;
+ match_key = pos->first;
+ }
+ match_value = pos->second;
+ return true;
+ }
+ return false;
+ }
+
+ iterator lower_bound_unsafe(const _Key &key) {
+ return m_collection.lower_bound(key);
+ }
+
+ void SetValueForKey(const _Key &key, const _Tp &value) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ SetValueForKeyNoLock(key, value);
+ }
+
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ void SetValueForKeyNoLock(const _Key &key, const _Tp &value) {
+ m_collection[key] = value;
+ }
- ~ThreadSafeSTLMap()
- {
- }
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.empty();
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.clear();
- }
-
- size_t
- Erase(const _Key &key)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return EraseNoLock(key);
- }
-
- size_t
- EraseNoLock (const _Key& key)
- {
- return m_collection.erase (key);
- }
-
- bool
- GetValueForKey(const _Key &key, _Tp &value) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return GetValueForKeyNoLock(key, value);
- }
-
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- bool
- GetValueForKeyNoLock (const _Key& key, _Tp &value) const
- {
- const_iterator pos = m_collection.find(key);
- if (pos != m_collection.end())
- {
- value = pos->second;
- return true;
- }
- return false;
- }
-
- bool
- GetFirstKeyForValue(const _Tp &value, _Key &key) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return GetFirstKeyForValueNoLock(value, key);
- }
-
- bool
- GetFirstKeyForValueNoLock (const _Tp &value, _Key& key) const
- {
- const_iterator pos, end = m_collection.end();
- for (pos = m_collection.begin(); pos != end; ++pos)
- {
- if (pos->second == value)
- {
- key = pos->first;
- return true;
- }
- }
- return false;
- }
-
- bool
- LowerBound(const _Key &key, _Key &match_key, _Tp &match_value, bool decrement_if_not_equal) const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return LowerBoundNoLock(key, match_key, match_value, decrement_if_not_equal);
- }
-
- bool
- LowerBoundNoLock (const _Key& key,
- _Key& match_key,
- _Tp &match_value,
- bool decrement_if_not_equal) const
- {
- const_iterator pos = m_collection.lower_bound (key);
- if (pos != m_collection.end())
- {
- match_key = pos->first;
- if (decrement_if_not_equal && key != match_key && pos != m_collection.begin())
- {
- --pos;
- match_key = pos->first;
- }
- match_value = pos->second;
- return true;
- }
- return false;
- }
-
- iterator
- lower_bound_unsafe (const _Key& key)
- {
- return m_collection.lower_bound (key);
- }
-
- void
- SetValueForKey(const _Key &key, const _Tp &value)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- SetValueForKeyNoLock(key, value);
- }
-
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- void
- SetValueForKeyNoLock (const _Key& key, const _Tp &value)
- {
- m_collection[key] = value;
- }
-
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
+ std::recursive_mutex &GetMutex() { return m_mutex; }
private:
- collection m_collection;
- mutable std::recursive_mutex m_mutex;
+ collection m_collection;
+ mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
- // For ThreadSafeSTLMap only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeSTLMap);
+ //------------------------------------------------------------------
+ // For ThreadSafeSTLMap only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLMap);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadSafeSTLMap_h_
+#endif // liblldb_ThreadSafeSTLMap_h_
Modified: lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h (original)
+++ lldb/trunk/include/lldb/Core/ThreadSafeSTLVector.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ThreadSafeSTLVector.h ------------------------------------*- C++ -*-===//
+//===-- ThreadSafeSTLVector.h ------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,88 +13,69 @@
// C Includes
// C++ Includes
-#include <vector>
#include <mutex>
+#include <vector>
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
namespace lldb_private {
-
- template <typename _Object>
- class ThreadSafeSTLVector
- {
- public:
- typedef std::vector<_Object> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeSTLVector() : m_collection(), m_mutex() {}
-
- ~ThreadSafeSTLVector() = default;
-
- bool
- IsEmpty() const
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.empty();
- }
-
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.clear();
- }
-
- size_t
- GetCount()
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.size();
- }
-
- void
- AppendObject (_Object& object)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_collection.push_back(object);
- }
-
- _Object
- GetObject (size_t index)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return m_collection.at(index);
- }
-
- void
- SetObject (size_t index, const _Object& object)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_collection.at(index) = object;
- }
-
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
-
- private:
- collection m_collection;
- mutable std::recursive_mutex m_mutex;
-
- //------------------------------------------------------------------
- // For ThreadSafeSTLVector only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeSTLVector);
- };
-
-
+
+template <typename _Object> class ThreadSafeSTLVector {
+public:
+ typedef std::vector<_Object> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeSTLVector() : m_collection(), m_mutex() {}
+
+ ~ThreadSafeSTLVector() = default;
+
+ bool IsEmpty() const {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.empty();
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.clear();
+ }
+
+ size_t GetCount() {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.size();
+ }
+
+ void AppendObject(_Object &object) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_collection.push_back(object);
+ }
+
+ _Object GetObject(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return m_collection.at(index);
+ }
+
+ void SetObject(size_t index, const _Object &object) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_collection.at(index) = object;
+ }
+
+ std::recursive_mutex &GetMutex() { return m_mutex; }
+
+private:
+ collection m_collection;
+ mutable std::recursive_mutex m_mutex;
+
+ //------------------------------------------------------------------
+ // For ThreadSafeSTLVector only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLVector);
+};
+
} // namespace lldb_private
-#endif // liblldb_ThreadSafeSTLVector_h_
+#endif // liblldb_ThreadSafeSTLVector_h_
Modified: lldb/trunk/include/lldb/Core/ThreadSafeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeValue.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeValue.h (original)
+++ lldb/trunk/include/lldb/Core/ThreadSafeValue.h Tue Sep 6 15:57:50 2016
@@ -20,71 +20,50 @@
namespace lldb_private {
-template <class T>
-class ThreadSafeValue
-{
+template <class T> class ThreadSafeValue {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeValue() : m_value(), m_mutex() {}
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeValue() : m_value(), m_mutex() {}
- ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
+ ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
- ~ThreadSafeValue()
- {
- }
+ ~ThreadSafeValue() {}
- T
- GetValue() const
+ T GetValue() const {
+ T value;
{
- T value;
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- value = m_value;
- }
- return value;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ value = m_value;
}
+ return value;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- const T&
- GetValueNoLock () const
- {
- return m_value;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ const T &GetValueNoLock() const { return m_value; }
- void
- SetValue(const T &value)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_value = value;
- }
+ void SetValue(const T &value) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_value = value;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- void
- SetValueNoLock (const T& value)
- {
- m_value = value;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ void SetValueNoLock(const T &value) { m_value = value; }
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
+ std::recursive_mutex &GetMutex() { return m_mutex; }
private:
- T m_value;
- mutable std::recursive_mutex m_mutex;
+ T m_value;
+ mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
- // For ThreadSafeValue only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeValue);
+ //------------------------------------------------------------------
+ // For ThreadSafeValue only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadSafeValue_h_
+#endif // liblldb_ThreadSafeValue_h_
Modified: lldb/trunk/include/lldb/Core/Timer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Timer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Timer.h (original)
+++ lldb/trunk/include/lldb/Core/Timer.h Tue Sep 6 15:57:50 2016
@@ -20,8 +20,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Host/TimeValue.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -37,120 +37,93 @@ namespace lldb_private {
/// in a scope.
//----------------------------------------------------------------------
-class Timer
-{
+class Timer {
public:
- //--------------------------------------------------------------
- /// Default constructor.
- //--------------------------------------------------------------
- Timer(const char *category, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
-
- //--------------------------------------------------------------
- /// Destructor
- //--------------------------------------------------------------
- ~Timer();
-
- void
- Dump ();
-
- static void
- SetDisplayDepth (uint32_t depth);
-
- static void
- SetQuiet (bool value);
+ //--------------------------------------------------------------
+ /// Default constructor.
+ //--------------------------------------------------------------
+ Timer(const char *category, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+
+ //--------------------------------------------------------------
+ /// Destructor
+ //--------------------------------------------------------------
+ ~Timer();
+
+ void Dump();
- static void
- DumpCategoryTimes (Stream *s);
+ static void SetDisplayDepth(uint32_t depth);
- static void
- ResetCategoryTimes ();
+ static void SetQuiet(bool value);
+
+ static void DumpCategoryTimes(Stream *s);
+
+ static void ResetCategoryTimes();
protected:
- void
- ChildStarted (const TimeValue& time);
+ void ChildStarted(const TimeValue &time);
+
+ void ChildStopped(const TimeValue &time);
- void
- ChildStopped (const TimeValue& time);
+ uint64_t GetTotalElapsedNanoSeconds();
- uint64_t
- GetTotalElapsedNanoSeconds();
+ uint64_t GetTimerElapsedNanoSeconds();
- uint64_t
- GetTimerElapsedNanoSeconds();
-
- const char *m_category;
- TimeValue m_total_start;
- TimeValue m_timer_start;
- uint64_t m_total_ticks; // Total running time for this timer including when other timers below this are running
- uint64_t m_timer_ticks; // Ticks for this timer that do not include when other timers below this one are running
+ const char *m_category;
+ TimeValue m_total_start;
+ TimeValue m_timer_start;
+ uint64_t m_total_ticks; // Total running time for this timer including when
+ // other timers below this are running
+ uint64_t m_timer_ticks; // Ticks for this timer that do not include when other
+ // timers below this one are running
- static std::atomic<bool> g_quiet;
- static std::atomic<unsigned> g_display_depth;
+ static std::atomic<bool> g_quiet;
+ static std::atomic<unsigned> g_display_depth;
private:
- Timer();
- DISALLOW_COPY_AND_ASSIGN (Timer);
+ Timer();
+ DISALLOW_COPY_AND_ASSIGN(Timer);
};
-
-class IntervalTimer
-{
+
+class IntervalTimer {
public:
- IntervalTimer() :
- m_start (TimeValue::Now())
- {
- }
+ IntervalTimer() : m_start(TimeValue::Now()) {}
- ~IntervalTimer() = default;
+ ~IntervalTimer() = default;
- uint64_t
- GetElapsedNanoSeconds() const
- {
- return TimeValue::Now() - m_start;
- }
-
- void
- Reset ()
- {
- m_start = TimeValue::Now();
- }
-
- int
- PrintfElapsed (const char *format, ...) __attribute__ ((format (printf, 2, 3)))
- {
- TimeValue now (TimeValue::Now());
- const uint64_t elapsed_nsec = now - m_start;
- const char *unit = nullptr;
- float elapsed_value;
- if (elapsed_nsec < 1000)
- {
- unit = "ns";
- elapsed_value = (float)elapsed_nsec;
- }
- else if (elapsed_nsec < 1000000)
- {
- unit = "us";
- elapsed_value = (float)elapsed_nsec/1000.0f;
- }
- else if (elapsed_nsec < 1000000000)
- {
- unit = "ms";
- elapsed_value = (float)elapsed_nsec/1000000.0f;
- }
- else
- {
- unit = "sec";
- elapsed_value = (float)elapsed_nsec/1000000000.0f;
- }
- int result = printf ("%3.2f %s: ", elapsed_value, unit);
- va_list args;
- va_start (args, format);
- result += vprintf (format, args);
- va_end (args);
- return result;
+ uint64_t GetElapsedNanoSeconds() const { return TimeValue::Now() - m_start; }
+
+ void Reset() { m_start = TimeValue::Now(); }
+
+ int PrintfElapsed(const char *format, ...)
+ __attribute__((format(printf, 2, 3))) {
+ TimeValue now(TimeValue::Now());
+ const uint64_t elapsed_nsec = now - m_start;
+ const char *unit = nullptr;
+ float elapsed_value;
+ if (elapsed_nsec < 1000) {
+ unit = "ns";
+ elapsed_value = (float)elapsed_nsec;
+ } else if (elapsed_nsec < 1000000) {
+ unit = "us";
+ elapsed_value = (float)elapsed_nsec / 1000.0f;
+ } else if (elapsed_nsec < 1000000000) {
+ unit = "ms";
+ elapsed_value = (float)elapsed_nsec / 1000000.0f;
+ } else {
+ unit = "sec";
+ elapsed_value = (float)elapsed_nsec / 1000000000.0f;
}
+ int result = printf("%3.2f %s: ", elapsed_value, unit);
+ va_list args;
+ va_start(args, format);
+ result += vprintf(format, args);
+ va_end(args);
+ return result;
+ }
protected:
- TimeValue m_start;
+ TimeValue m_start;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/UUID.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UUID.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UUID.h (original)
+++ lldb/trunk/include/lldb/Core/UUID.h Tue Sep 6 15:57:50 2016
@@ -20,91 +20,83 @@
namespace lldb_private {
-class UUID
-{
+class UUID {
public:
- // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
- typedef uint8_t ValueType[20];
+ // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20.
+ typedef uint8_t ValueType[20];
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ UUID();
+ UUID(const UUID &rhs);
+ UUID(const void *uuid_bytes, uint32_t num_uuid_bytes);
+
+ ~UUID();
+
+ const UUID &operator=(const UUID &rhs);
+
+ void Clear();
+
+ void Dump(Stream *s) const;
+
+ const void *GetBytes() const;
+
+ size_t GetByteSize();
+
+ bool IsValid() const;
+
+ bool SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
+
+ std::string GetAsString(const char *separator = nullptr) const;
+
+ size_t SetFromCString(const char *c_str, uint32_t num_uuid_bytes = 16);
+
+ // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
+ // This is used for auto completion where a partial UUID might have been
+ // typed in. It
+ //------------------------------------------------------------------
+ /// Decode as many UUID bytes (up to 16) as possible from the C
+ /// string \a cstr.
+ ///
+ /// @param[in] cstr
+ /// A NULL terminate C string that points at a UUID string value
+ /// (no leading spaces). The string must contain only hex
+ /// characters and optionally can contain the '-' sepearators.
+ ///
+ /// @param[in] uuid_bytes
+ /// A buffer of bytes that will contain a full or patially
+ /// decoded UUID.
+ ///
+ /// @param[out] end
+ /// If \a end is not nullptr, it will be filled in with the a
+ /// pointer to the character after the last successfully decoded
+ /// byte.
+ ///
+ /// @return
+ /// Returns the number of bytes that were successfully decoded
+ /// which should be 16 if a full UUID value was properly decoded.
+ //------------------------------------------------------------------
+ static size_t DecodeUUIDBytesFromCString(const char *cstr,
+ ValueType &uuid_bytes,
+ const char **end,
+ uint32_t num_uuid_bytes = 16);
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- UUID ();
- UUID (const UUID& rhs);
- UUID (const void *uuid_bytes, uint32_t num_uuid_bytes);
-
- ~UUID ();
-
- const UUID&
- operator=(const UUID& rhs);
-
- void
- Clear ();
-
- void
- Dump (Stream *s) const;
-
- const void *
- GetBytes() const;
-
- size_t
- GetByteSize();
-
- bool
- IsValid () const;
-
- bool
- SetBytes (const void *uuid_bytes, uint32_t num_uuid_bytes = 16);
-
- std::string
- GetAsString(const char *separator = nullptr) const;
-
- size_t
- SetFromCString (const char *c_str, uint32_t num_uuid_bytes = 16);
-
- // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
- // This is used for auto completion where a partial UUID might have been
- // typed in. It
- //------------------------------------------------------------------
- /// Decode as many UUID bytes (up to 16) as possible from the C
- /// string \a cstr.
- ///
- /// @param[in] cstr
- /// A NULL terminate C string that points at a UUID string value
- /// (no leading spaces). The string must contain only hex
- /// characters and optionally can contain the '-' sepearators.
- ///
- /// @param[in] uuid_bytes
- /// A buffer of bytes that will contain a full or patially
- /// decoded UUID.
- ///
- /// @param[out] end
- /// If \a end is not nullptr, it will be filled in with the a
- /// pointer to the character after the last successfully decoded
- /// byte.
- ///
- /// @return
- /// Returns the number of bytes that were successfully decoded
- /// which should be 16 if a full UUID value was properly decoded.
- //------------------------------------------------------------------
- static size_t
- DecodeUUIDBytesFromCString (const char *cstr, ValueType &uuid_bytes, const char **end, uint32_t num_uuid_bytes = 16);
-
protected:
- //------------------------------------------------------------------
- // Classes that inherit from UUID can see and modify these
- //------------------------------------------------------------------
- uint32_t m_num_uuid_bytes; // Should be 16 or 20
- ValueType m_uuid;
+ //------------------------------------------------------------------
+ // Classes that inherit from UUID can see and modify these
+ //------------------------------------------------------------------
+ uint32_t m_num_uuid_bytes; // Should be 16 or 20
+ ValueType m_uuid;
};
-bool operator == (const UUID &lhs, const UUID &rhs);
-bool operator != (const UUID &lhs, const UUID &rhs);
-bool operator < (const UUID &lhs, const UUID &rhs);
-bool operator <= (const UUID &lhs, const UUID &rhs);
-bool operator > (const UUID &lhs, const UUID &rhs);
-bool operator >= (const UUID &lhs, const UUID &rhs);
+bool operator==(const UUID &lhs, const UUID &rhs);
+bool operator!=(const UUID &lhs, const UUID &rhs);
+bool operator<(const UUID &lhs, const UUID &rhs);
+bool operator<=(const UUID &lhs, const UUID &rhs);
+bool operator>(const UUID &lhs, const UUID &rhs);
+bool operator>=(const UUID &lhs, const UUID &rhs);
} // namespace lldb_private
-#endif // liblldb_UUID_h_
+#endif // liblldb_UUID_h_
Modified: lldb/trunk/include/lldb/Core/UniqueCStringMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UniqueCStringMap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UniqueCStringMap.h (original)
+++ lldb/trunk/include/lldb/Core/UniqueCStringMap.h Tue Sep 6 15:57:50 2016
@@ -30,326 +30,240 @@ namespace lldb_private {
// Any other string table that has guaranteed unique values can also
// be used.
//----------------------------------------------------------------------
-template <typename T>
-class UniqueCStringMap
-{
+template <typename T> class UniqueCStringMap {
public:
- struct Entry
- {
- Entry () :
- cstring(nullptr),
- value()
- {
- }
-
- Entry (const char *cstr) :
- cstring(cstr),
- value()
- {
- }
-
- Entry (const char *cstr, const T&v) :
- cstring(cstr),
- value(v)
- {
- }
-
- bool
- operator < (const Entry& rhs) const
- {
- return cstring < rhs.cstring;
- }
-
- const char* cstring;
- T value;
- };
-
- //------------------------------------------------------------------
- // Call this function multiple times to add a bunch of entries to
- // this map, then later call UniqueCStringMap<T>::Sort() before doing
- // any searches by name.
- //------------------------------------------------------------------
- void
- Append (const char *unique_cstr, const T& value)
- {
- m_map.push_back (typename UniqueCStringMap<T>::Entry(unique_cstr, value));
- }
-
- void
- Append (const Entry &e)
- {
- m_map.push_back (e);
- }
-
- void
- Clear ()
- {
- m_map.clear();
- }
-
- //------------------------------------------------------------------
- // Call this function to always keep the map sorted when putting
- // entries into the map.
- //------------------------------------------------------------------
- void
- Insert (const char *unique_cstr, const T& value)
- {
- typename UniqueCStringMap<T>::Entry e(unique_cstr, value);
- m_map.insert (std::upper_bound (m_map.begin(), m_map.end(), e), e);
- }
-
- void
- Insert (const Entry &e)
- {
- m_map.insert (std::upper_bound (m_map.begin(), m_map.end(), e), e);
- }
-
- //------------------------------------------------------------------
- // Get an entries by index in a variety of forms.
- //
- // The caller is responsible for ensuring that the collection does
- // not change during while using the returned values.
- //------------------------------------------------------------------
- bool
- GetValueAtIndex (uint32_t idx, T &value) const
- {
- if (idx < m_map.size())
- {
- value = m_map[idx].value;
- return true;
- }
- return false;
- }
-
- const char *
- GetCStringAtIndexUnchecked (uint32_t idx) const
- {
- return m_map[idx].cstring;
- }
-
- // Use this function if you have simple types in your map that you
- // can easily copy when accessing values by index.
- T
- GetValueAtIndexUnchecked (uint32_t idx) const
- {
- return m_map[idx].value;
- }
-
- // Use this function if you have complex types in your map that you
- // don't want to copy when accessing values by index.
- const T &
- GetValueRefAtIndexUnchecked (uint32_t idx) const
- {
- return m_map[idx].value;
- }
+ struct Entry {
+ Entry() : cstring(nullptr), value() {}
- const char *
- GetCStringAtIndex (uint32_t idx) const
- {
- return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr);
- }
+ Entry(const char *cstr) : cstring(cstr), value() {}
- //------------------------------------------------------------------
- // Find the value for the unique string in the map.
- //
- // Return the value for \a unique_cstr if one is found, return
- // \a fail_value otherwise. This method works well for simple type
- // T values and only if there is a sensible failure value that can
- // be returned and that won't match any existing values.
- //------------------------------------------------------------------
- T
- Find (const char *unique_cstr, T fail_value) const
- {
- Entry search_entry (unique_cstr);
- const_iterator end = m_map.end();
- const_iterator pos = std::lower_bound (m_map.begin(), end, search_entry);
- if (pos != end)
- {
- if (pos->cstring == unique_cstr)
- return pos->value;
- }
- return fail_value;
- }
+ Entry(const char *cstr, const T &v) : cstring(cstr), value(v) {}
- //------------------------------------------------------------------
- // Get a pointer to the first entry that matches "name". nullptr will
- // be returned if there is no entry that matches "name".
- //
- // The caller is responsible for ensuring that the collection does
- // not change during while using the returned pointer.
- //------------------------------------------------------------------
- const Entry *
- FindFirstValueForName (const char *unique_cstr) const
- {
- Entry search_entry (unique_cstr);
- const_iterator end = m_map.end();
- const_iterator pos = std::lower_bound (m_map.begin(), end, search_entry);
- if (pos != end)
- {
- const char *pos_cstr = pos->cstring;
- if (pos_cstr == unique_cstr)
- return &(*pos);
- }
- return nullptr;
- }
-
- //------------------------------------------------------------------
- // Get a pointer to the next entry that matches "name" from a
- // previously returned Entry pointer. nullptr will be returned if there
- // is no subsequent entry that matches "name".
- //
- // The caller is responsible for ensuring that the collection does
- // not change during while using the returned pointer.
- //------------------------------------------------------------------
- const Entry *
- FindNextValueForName (const Entry *entry_ptr) const
- {
- if (!m_map.empty())
- {
- const Entry *first_entry = &m_map[0];
- const Entry *after_last_entry = first_entry + m_map.size();
- const Entry *next_entry = entry_ptr + 1;
- if (first_entry <= next_entry && next_entry < after_last_entry)
- {
- if (next_entry->cstring == entry_ptr->cstring)
- return next_entry;
- }
- }
- return nullptr;
- }
-
- size_t
- GetValues (const char *unique_cstr, std::vector<T> &values) const
- {
- const size_t start_size = values.size();
-
- Entry search_entry (unique_cstr);
- const_iterator pos, end = m_map.end();
- for (pos = std::lower_bound (m_map.begin(), end, search_entry); pos != end; ++pos)
- {
- if (pos->cstring == unique_cstr)
- values.push_back (pos->value);
- else
- break;
- }
-
- return values.size() - start_size;
- }
-
- size_t
- GetValues (const RegularExpression& regex, std::vector<T> &values) const
- {
- const size_t start_size = values.size();
-
- const_iterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; ++pos)
- {
- if (regex.Execute(pos->cstring))
- values.push_back (pos->value);
- }
-
- return values.size() - start_size;
- }
-
- //------------------------------------------------------------------
- // Get the total number of entries in this map.
- //------------------------------------------------------------------
- size_t
- GetSize () const
- {
- return m_map.size();
- }
-
- //------------------------------------------------------------------
- // Returns true if this map is empty.
- //------------------------------------------------------------------
- bool
- IsEmpty() const
- {
- return m_map.empty();
- }
-
- //------------------------------------------------------------------
- // Reserve memory for at least "n" entries in the map. This is
- // useful to call when you know you will be adding a lot of entries
- // using UniqueCStringMap::Append() (which should be followed by a
- // call to UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert().
- //------------------------------------------------------------------
- void
- Reserve (size_t n)
- {
- m_map.reserve (n);
- }
-
- //------------------------------------------------------------------
- // Sort the unsorted contents in this map. A typical code flow would
- // be:
- // size_t approximate_num_entries = ....
- // UniqueCStringMap<uint32_t> my_map;
- // my_map.Reserve (approximate_num_entries);
- // for (...)
- // {
- // my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...)));
- // }
- // my_map.Sort();
- //------------------------------------------------------------------
- void
- Sort ()
- {
- std::sort (m_map.begin(), m_map.end());
- }
-
- //------------------------------------------------------------------
- // Since we are using a vector to contain our items it will always
- // double its memory consumption as things are added to the vector,
- // so if you intend to keep a UniqueCStringMap around and have
- // a lot of entries in the map, you will want to call this function
- // to create a new vector and copy _only_ the exact size needed as
- // part of the finalization of the string map.
- //------------------------------------------------------------------
- void
- SizeToFit ()
- {
- if (m_map.size() < m_map.capacity())
- {
- collection temp (m_map.begin(), m_map.end());
- m_map.swap(temp);
- }
- }
+ bool operator<(const Entry &rhs) const { return cstring < rhs.cstring; }
- size_t
- Erase (const char *unique_cstr)
- {
- size_t num_removed = 0;
- Entry search_entry (unique_cstr);
- iterator end = m_map.end();
- iterator begin = m_map.begin();
- iterator lower_pos = std::lower_bound (begin, end, search_entry);
- if (lower_pos != end)
- {
- if (lower_pos->cstring == unique_cstr)
- {
- iterator upper_pos = std::upper_bound (lower_pos, end, search_entry);
- if (lower_pos == upper_pos)
- {
- m_map.erase (lower_pos);
- num_removed = 1;
- }
- else
- {
- num_removed = std::distance (lower_pos, upper_pos);
- m_map.erase (lower_pos, upper_pos);
- }
- }
+ const char *cstring;
+ T value;
+ };
+
+ //------------------------------------------------------------------
+ // Call this function multiple times to add a bunch of entries to
+ // this map, then later call UniqueCStringMap<T>::Sort() before doing
+ // any searches by name.
+ //------------------------------------------------------------------
+ void Append(const char *unique_cstr, const T &value) {
+ m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
+ }
+
+ void Append(const Entry &e) { m_map.push_back(e); }
+
+ void Clear() { m_map.clear(); }
+
+ //------------------------------------------------------------------
+ // Call this function to always keep the map sorted when putting
+ // entries into the map.
+ //------------------------------------------------------------------
+ void Insert(const char *unique_cstr, const T &value) {
+ typename UniqueCStringMap<T>::Entry e(unique_cstr, value);
+ m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e);
+ }
+
+ void Insert(const Entry &e) {
+ m_map.insert(std::upper_bound(m_map.begin(), m_map.end(), e), e);
+ }
+
+ //------------------------------------------------------------------
+ // Get an entries by index in a variety of forms.
+ //
+ // The caller is responsible for ensuring that the collection does
+ // not change during while using the returned values.
+ //------------------------------------------------------------------
+ bool GetValueAtIndex(uint32_t idx, T &value) const {
+ if (idx < m_map.size()) {
+ value = m_map[idx].value;
+ return true;
+ }
+ return false;
+ }
+
+ const char *GetCStringAtIndexUnchecked(uint32_t idx) const {
+ return m_map[idx].cstring;
+ }
+
+ // Use this function if you have simple types in your map that you
+ // can easily copy when accessing values by index.
+ T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; }
+
+ // Use this function if you have complex types in your map that you
+ // don't want to copy when accessing values by index.
+ const T &GetValueRefAtIndexUnchecked(uint32_t idx) const {
+ return m_map[idx].value;
+ }
+
+ const char *GetCStringAtIndex(uint32_t idx) const {
+ return ((idx < m_map.size()) ? m_map[idx].cstring : nullptr);
+ }
+
+ //------------------------------------------------------------------
+ // Find the value for the unique string in the map.
+ //
+ // Return the value for \a unique_cstr if one is found, return
+ // \a fail_value otherwise. This method works well for simple type
+ // T values and only if there is a sensible failure value that can
+ // be returned and that won't match any existing values.
+ //------------------------------------------------------------------
+ T Find(const char *unique_cstr, T fail_value) const {
+ Entry search_entry(unique_cstr);
+ const_iterator end = m_map.end();
+ const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry);
+ if (pos != end) {
+ if (pos->cstring == unique_cstr)
+ return pos->value;
+ }
+ return fail_value;
+ }
+
+ //------------------------------------------------------------------
+ // Get a pointer to the first entry that matches "name". nullptr will
+ // be returned if there is no entry that matches "name".
+ //
+ // The caller is responsible for ensuring that the collection does
+ // not change during while using the returned pointer.
+ //------------------------------------------------------------------
+ const Entry *FindFirstValueForName(const char *unique_cstr) const {
+ Entry search_entry(unique_cstr);
+ const_iterator end = m_map.end();
+ const_iterator pos = std::lower_bound(m_map.begin(), end, search_entry);
+ if (pos != end) {
+ const char *pos_cstr = pos->cstring;
+ if (pos_cstr == unique_cstr)
+ return &(*pos);
+ }
+ return nullptr;
+ }
+
+ //------------------------------------------------------------------
+ // Get a pointer to the next entry that matches "name" from a
+ // previously returned Entry pointer. nullptr will be returned if there
+ // is no subsequent entry that matches "name".
+ //
+ // The caller is responsible for ensuring that the collection does
+ // not change during while using the returned pointer.
+ //------------------------------------------------------------------
+ const Entry *FindNextValueForName(const Entry *entry_ptr) const {
+ if (!m_map.empty()) {
+ const Entry *first_entry = &m_map[0];
+ const Entry *after_last_entry = first_entry + m_map.size();
+ const Entry *next_entry = entry_ptr + 1;
+ if (first_entry <= next_entry && next_entry < after_last_entry) {
+ if (next_entry->cstring == entry_ptr->cstring)
+ return next_entry;
+ }
+ }
+ return nullptr;
+ }
+
+ size_t GetValues(const char *unique_cstr, std::vector<T> &values) const {
+ const size_t start_size = values.size();
+
+ Entry search_entry(unique_cstr);
+ const_iterator pos, end = m_map.end();
+ for (pos = std::lower_bound(m_map.begin(), end, search_entry); pos != end;
+ ++pos) {
+ if (pos->cstring == unique_cstr)
+ values.push_back(pos->value);
+ else
+ break;
+ }
+
+ return values.size() - start_size;
+ }
+
+ size_t GetValues(const RegularExpression ®ex,
+ std::vector<T> &values) const {
+ const size_t start_size = values.size();
+
+ const_iterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; ++pos) {
+ if (regex.Execute(pos->cstring))
+ values.push_back(pos->value);
+ }
+
+ return values.size() - start_size;
+ }
+
+ //------------------------------------------------------------------
+ // Get the total number of entries in this map.
+ //------------------------------------------------------------------
+ size_t GetSize() const { return m_map.size(); }
+
+ //------------------------------------------------------------------
+ // Returns true if this map is empty.
+ //------------------------------------------------------------------
+ bool IsEmpty() const { return m_map.empty(); }
+
+ //------------------------------------------------------------------
+ // Reserve memory for at least "n" entries in the map. This is
+ // useful to call when you know you will be adding a lot of entries
+ // using UniqueCStringMap::Append() (which should be followed by a
+ // call to UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert().
+ //------------------------------------------------------------------
+ void Reserve(size_t n) { m_map.reserve(n); }
+
+ //------------------------------------------------------------------
+ // Sort the unsorted contents in this map. A typical code flow would
+ // be:
+ // size_t approximate_num_entries = ....
+ // UniqueCStringMap<uint32_t> my_map;
+ // my_map.Reserve (approximate_num_entries);
+ // for (...)
+ // {
+ // my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...)));
+ // }
+ // my_map.Sort();
+ //------------------------------------------------------------------
+ void Sort() { std::sort(m_map.begin(), m_map.end()); }
+
+ //------------------------------------------------------------------
+ // Since we are using a vector to contain our items it will always
+ // double its memory consumption as things are added to the vector,
+ // so if you intend to keep a UniqueCStringMap around and have
+ // a lot of entries in the map, you will want to call this function
+ // to create a new vector and copy _only_ the exact size needed as
+ // part of the finalization of the string map.
+ //------------------------------------------------------------------
+ void SizeToFit() {
+ if (m_map.size() < m_map.capacity()) {
+ collection temp(m_map.begin(), m_map.end());
+ m_map.swap(temp);
+ }
+ }
+
+ size_t Erase(const char *unique_cstr) {
+ size_t num_removed = 0;
+ Entry search_entry(unique_cstr);
+ iterator end = m_map.end();
+ iterator begin = m_map.begin();
+ iterator lower_pos = std::lower_bound(begin, end, search_entry);
+ if (lower_pos != end) {
+ if (lower_pos->cstring == unique_cstr) {
+ iterator upper_pos = std::upper_bound(lower_pos, end, search_entry);
+ if (lower_pos == upper_pos) {
+ m_map.erase(lower_pos);
+ num_removed = 1;
+ } else {
+ num_removed = std::distance(lower_pos, upper_pos);
+ m_map.erase(lower_pos, upper_pos);
}
- return num_removed;
+ }
}
+ return num_removed;
+ }
protected:
- typedef std::vector<Entry> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
- collection m_map;
+ typedef std::vector<Entry> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+ collection m_map;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/UserID.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserID.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserID.h (original)
+++ lldb/trunk/include/lldb/Core/UserID.h Tue Sep 6 15:57:50 2016
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef liblldb_UserID_h_
#define liblldb_UserID_h_
@@ -30,101 +29,90 @@ namespace lldb_private {
/// index, functions can use it to store the symbol table index or the
/// DWARF offset.
//----------------------------------------------------------------------
-struct UserID
-{
- //------------------------------------------------------------------
- /// Construct with optional user ID.
- //------------------------------------------------------------------
- UserID (lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
-
- //------------------------------------------------------------------
- /// Destructor.
- //------------------------------------------------------------------
- ~UserID ()
- {
- }
-
- //------------------------------------------------------------------
- /// Clears the object state.
- ///
- /// Clears the object contents back to a default invalid state.
- //------------------------------------------------------------------
- void
- Clear () { m_uid = LLDB_INVALID_UID; }
-
- //------------------------------------------------------------------
- /// Get accessor for the user ID.
- ///
- /// @return
- /// The user ID.
- //------------------------------------------------------------------
- lldb::user_id_t
- GetID () const { return m_uid; }
-
- //------------------------------------------------------------------
- /// Set accessor for the user ID.
- ///
- /// @param[in] uid
- /// The new user ID.
- //------------------------------------------------------------------
- void
- SetID (lldb::user_id_t uid) { m_uid = uid; }
-
- //------------------------------------------------------------------
- /// Unary predicate function object that can search for a matching
- /// user ID.
- ///
- /// Function object that can be used on any class that inherits
- /// from UserID:
- /// \code
- /// iterator pos;
- /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
- /// \endcode
- //------------------------------------------------------------------
- class IDMatches
- {
- public:
- //--------------------------------------------------------------
- /// Construct with the user ID to look for.
- //--------------------------------------------------------------
- IDMatches (lldb::user_id_t uid) : m_uid(uid) {}
-
- //--------------------------------------------------------------
- /// Unary predicate function object callback.
- //--------------------------------------------------------------
- bool
- operator () (const UserID& rhs) const { return m_uid == rhs.GetID(); }
-
- private:
- //--------------------------------------------------------------
- // Member variables.
- //--------------------------------------------------------------
- const lldb::user_id_t m_uid; ///< The user ID we are looking for
- };
+struct UserID {
+ //------------------------------------------------------------------
+ /// Construct with optional user ID.
+ //------------------------------------------------------------------
+ UserID(lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {}
+
+ //------------------------------------------------------------------
+ /// Destructor.
+ //------------------------------------------------------------------
+ ~UserID() {}
+
+ //------------------------------------------------------------------
+ /// Clears the object state.
+ ///
+ /// Clears the object contents back to a default invalid state.
+ //------------------------------------------------------------------
+ void Clear() { m_uid = LLDB_INVALID_UID; }
+
+ //------------------------------------------------------------------
+ /// Get accessor for the user ID.
+ ///
+ /// @return
+ /// The user ID.
+ //------------------------------------------------------------------
+ lldb::user_id_t GetID() const { return m_uid; }
+
+ //------------------------------------------------------------------
+ /// Set accessor for the user ID.
+ ///
+ /// @param[in] uid
+ /// The new user ID.
+ //------------------------------------------------------------------
+ void SetID(lldb::user_id_t uid) { m_uid = uid; }
+
+ //------------------------------------------------------------------
+ /// Unary predicate function object that can search for a matching
+ /// user ID.
+ ///
+ /// Function object that can be used on any class that inherits
+ /// from UserID:
+ /// \code
+ /// iterator pos;
+ /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID));
+ /// \endcode
+ //------------------------------------------------------------------
+ class IDMatches {
+ public:
+ //--------------------------------------------------------------
+ /// Construct with the user ID to look for.
+ //--------------------------------------------------------------
+ IDMatches(lldb::user_id_t uid) : m_uid(uid) {}
+
+ //--------------------------------------------------------------
+ /// Unary predicate function object callback.
+ //--------------------------------------------------------------
+ bool operator()(const UserID &rhs) const { return m_uid == rhs.GetID(); }
+ private:
+ //--------------------------------------------------------------
+ // Member variables.
+ //--------------------------------------------------------------
+ const lldb::user_id_t m_uid; ///< The user ID we are looking for
+ };
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object.
};
-inline bool operator== (const UserID& lhs, const UserID& rhs)
-{
+inline bool operator==(const UserID &lhs, const UserID &rhs) {
return lhs.GetID() == rhs.GetID();
}
-inline bool operator!= (const UserID& lhs, const UserID& rhs)
-{
+inline bool operator!=(const UserID &lhs, const UserID &rhs) {
return lhs.GetID() != rhs.GetID();
}
//--------------------------------------------------------------
/// Stream the UserID object to a Stream.
//--------------------------------------------------------------
-Stream& operator << (Stream& strm, const UserID& uid);
+Stream &operator<<(Stream &strm, const UserID &uid);
} // namespace lldb_private
-#endif // liblldb_UserID_h_
+#endif // liblldb_UserID_h_
Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//====-- UserSettingsController.h --------------------------------*- C++ -*-===//
+//====-- UserSettingsController.h --------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,91 +20,73 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/ConstString.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Properties
-{
+class Properties {
public:
- Properties () :
- m_collection_sp ()
- {
- }
-
- Properties (const lldb::OptionValuePropertiesSP &collection_sp) :
- m_collection_sp (collection_sp)
- {
- }
-
- virtual
- ~Properties()
- {
- }
-
- virtual lldb::OptionValuePropertiesSP
- GetValueProperties () const
- {
- // This function is virtual in case subclasses want to lazily
- // implement creating the properties.
- return m_collection_sp;
- }
-
- virtual lldb::OptionValueSP
- GetPropertyValue (const ExecutionContext *exe_ctx,
- const char *property_path,
- bool will_modify,
- Error &error) const;
-
- virtual Error
- SetPropertyValue (const ExecutionContext *exe_ctx,
- VarSetOperationType op,
- const char *property_path,
- const char *value);
-
- virtual Error
- DumpPropertyValue (const ExecutionContext *exe_ctx,
- Stream &strm,
- const char *property_path,
- uint32_t dump_mask);
-
- virtual void
- DumpAllPropertyValues (const ExecutionContext *exe_ctx,
- Stream &strm,
- uint32_t dump_mask);
-
- virtual void
- DumpAllDescriptions (CommandInterpreter &interpreter,
- Stream &strm) const;
-
- size_t
- Apropos (const char *keyword,
- std::vector<const Property *> &matching_properties) const;
-
- lldb::OptionValuePropertiesSP
- GetSubProperty (const ExecutionContext *exe_ctx,
- const ConstString &name);
-
- // We sometimes need to introduce a setting to enable experimental features,
- // but then we don't want the setting for these to cause errors when the setting
- // goes away. Add a sub-topic of the settings using this experimental name, and
- // two things will happen. One is that settings that don't find the name will not
- // be treated as errors. Also, if you decide to keep the settings just move them into
- // the containing properties, and we will auto-forward the experimental settings to the
- // real one.
- static const char *
- GetExperimentalSettingsName();
-
- static bool
- IsSettingExperimental(const char *setting);
+ Properties() : m_collection_sp() {}
+
+ Properties(const lldb::OptionValuePropertiesSP &collection_sp)
+ : m_collection_sp(collection_sp) {}
+
+ virtual ~Properties() {}
+
+ virtual lldb::OptionValuePropertiesSP GetValueProperties() const {
+ // This function is virtual in case subclasses want to lazily
+ // implement creating the properties.
+ return m_collection_sp;
+ }
+
+ virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx,
+ const char *property_path,
+ bool will_modify,
+ Error &error) const;
+
+ virtual Error SetPropertyValue(const ExecutionContext *exe_ctx,
+ VarSetOperationType op,
+ const char *property_path, const char *value);
+
+ virtual Error DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm,
+ const char *property_path,
+ uint32_t dump_mask);
+
+ virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
+ Stream &strm, uint32_t dump_mask);
+
+ virtual void DumpAllDescriptions(CommandInterpreter &interpreter,
+ Stream &strm) const;
+
+ size_t Apropos(const char *keyword,
+ std::vector<const Property *> &matching_properties) const;
+
+ lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
+ const ConstString &name);
+
+ // We sometimes need to introduce a setting to enable experimental features,
+ // but then we don't want the setting for these to cause errors when the
+ // setting
+ // goes away. Add a sub-topic of the settings using this experimental name,
+ // and
+ // two things will happen. One is that settings that don't find the name will
+ // not
+ // be treated as errors. Also, if you decide to keep the settings just move
+ // them into
+ // the containing properties, and we will auto-forward the experimental
+ // settings to the
+ // real one.
+ static const char *GetExperimentalSettingsName();
+
+ static bool IsSettingExperimental(const char *setting);
protected:
- lldb::OptionValuePropertiesSP m_collection_sp;
+ lldb::OptionValuePropertiesSP m_collection_sp;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/VMRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/VMRange.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/VMRange.h (original)
+++ lldb/trunk/include/lldb/Core/VMRange.h Tue Sep 6 15:57:50 2016
@@ -19,163 +19,108 @@ namespace lldb_private {
// A vm address range. These can represent offsets ranges or actual
// addresses.
//----------------------------------------------------------------------
-class VMRange
-{
+class VMRange {
public:
+ typedef std::vector<VMRange> collection;
+ typedef collection::iterator iterator;
+ typedef collection::const_iterator const_iterator;
- typedef std::vector<VMRange> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
-
- VMRange() :
- m_base_addr(0),
- m_byte_size(0)
- {
- }
+ VMRange() : m_base_addr(0), m_byte_size(0) {}
- VMRange(lldb::addr_t start_addr, lldb::addr_t end_addr) :
- m_base_addr(start_addr),
- m_byte_size(end_addr > start_addr ? end_addr - start_addr : 0)
- {
- }
+ VMRange(lldb::addr_t start_addr, lldb::addr_t end_addr)
+ : m_base_addr(start_addr),
+ m_byte_size(end_addr > start_addr ? end_addr - start_addr : 0) {}
- ~VMRange()
- {
- }
+ ~VMRange() {}
- void
- Clear ()
- {
- m_base_addr = 0;
- m_byte_size = 0;
- }
+ void Clear() {
+ m_base_addr = 0;
+ m_byte_size = 0;
+ }
- // Set the start and end values
- void
- Reset (lldb::addr_t start_addr, lldb::addr_t end_addr)
- {
- SetBaseAddress (start_addr);
- SetEndAddress (end_addr);
- }
+ // Set the start and end values
+ void Reset(lldb::addr_t start_addr, lldb::addr_t end_addr) {
+ SetBaseAddress(start_addr);
+ SetEndAddress(end_addr);
+ }
- // Set the start value for the range, and keep the same size
- void
- SetBaseAddress (lldb::addr_t base_addr)
- {
- m_base_addr = base_addr;
- }
+ // Set the start value for the range, and keep the same size
+ void SetBaseAddress(lldb::addr_t base_addr) { m_base_addr = base_addr; }
- void
- SetEndAddress (lldb::addr_t end_addr)
- {
- const lldb::addr_t base_addr = GetBaseAddress();
- if (end_addr > base_addr)
- m_byte_size = end_addr - base_addr;
- else
- m_byte_size = 0;
- }
+ void SetEndAddress(lldb::addr_t end_addr) {
+ const lldb::addr_t base_addr = GetBaseAddress();
+ if (end_addr > base_addr)
+ m_byte_size = end_addr - base_addr;
+ else
+ m_byte_size = 0;
+ }
- lldb::addr_t
- GetByteSize () const
- {
- return m_byte_size;
- }
+ lldb::addr_t GetByteSize() const { return m_byte_size; }
- void
- SetByteSize (lldb::addr_t byte_size)
- {
- m_byte_size = byte_size;
- }
+ void SetByteSize(lldb::addr_t byte_size) { m_byte_size = byte_size; }
- lldb::addr_t
- GetBaseAddress () const
- {
- return m_base_addr;
- }
+ lldb::addr_t GetBaseAddress() const { return m_base_addr; }
- lldb::addr_t
- GetEndAddress () const
- {
- return GetBaseAddress() + m_byte_size;
- }
+ lldb::addr_t GetEndAddress() const { return GetBaseAddress() + m_byte_size; }
+
+ bool IsValid() const { return m_byte_size > 0; }
- bool
- IsValid() const
- {
- return m_byte_size > 0;
+ bool Contains(lldb::addr_t addr) const {
+ return (GetBaseAddress() <= addr) && (addr < GetEndAddress());
+ }
+
+ bool Contains(const VMRange &range) const {
+ if (Contains(range.GetBaseAddress())) {
+ lldb::addr_t range_end = range.GetEndAddress();
+ return (GetBaseAddress() <= range_end) && (range_end <= GetEndAddress());
}
+ return false;
+ }
+
+ void Dump(Stream *s, lldb::addr_t base_addr = 0,
+ uint32_t addr_width = 8) const;
- bool
- Contains (lldb::addr_t addr) const
- {
- return (GetBaseAddress() <= addr) && (addr < GetEndAddress());
+ class ValueInRangeUnaryPredicate {
+ public:
+ ValueInRangeUnaryPredicate(lldb::addr_t value) : _value(value) {}
+ bool operator()(const VMRange &range) const {
+ return range.Contains(_value);
}
+ lldb::addr_t _value;
+ };
- bool
- Contains (const VMRange& range) const
- {
- if (Contains(range.GetBaseAddress()))
- {
- lldb::addr_t range_end = range.GetEndAddress();
- return (GetBaseAddress() <= range_end) && (range_end <= GetEndAddress());
- }
- return false;
+ class RangeInRangeUnaryPredicate {
+ public:
+ RangeInRangeUnaryPredicate(VMRange range) : _range(range) {}
+ bool operator()(const VMRange &range) const {
+ return range.Contains(_range);
}
+ const VMRange &_range;
+ };
+
+ static bool ContainsValue(const VMRange::collection &coll,
+ lldb::addr_t value);
- void
- Dump (Stream *s, lldb::addr_t base_addr = 0, uint32_t addr_width = 8) const;
+ static bool ContainsRange(const VMRange::collection &coll,
+ const VMRange &range);
- class ValueInRangeUnaryPredicate
- {
- public:
- ValueInRangeUnaryPredicate(lldb::addr_t value) :
- _value(value)
- {
- }
- bool operator()(const VMRange& range) const
- {
- return range.Contains(_value);
- }
- lldb::addr_t _value;
- };
-
- class RangeInRangeUnaryPredicate
- {
- public:
- RangeInRangeUnaryPredicate(VMRange range) :
- _range(range)
- {
- }
- bool operator()(const VMRange& range) const
- {
- return range.Contains(_range);
- }
- const VMRange& _range;
- };
-
- static bool
- ContainsValue(const VMRange::collection& coll, lldb::addr_t value);
-
- static bool
- ContainsRange(const VMRange::collection& coll, const VMRange& range);
-
- // Returns a valid index into coll when a match is found, else UINT32_MAX
- // is returned
- static size_t
- FindRangeIndexThatContainsValue (const VMRange::collection& coll, lldb::addr_t value);
+ // Returns a valid index into coll when a match is found, else UINT32_MAX
+ // is returned
+ static size_t FindRangeIndexThatContainsValue(const VMRange::collection &coll,
+ lldb::addr_t value);
protected:
- lldb::addr_t m_base_addr;
- lldb::addr_t m_byte_size;
+ lldb::addr_t m_base_addr;
+ lldb::addr_t m_byte_size;
};
-bool operator== (const VMRange& lhs, const VMRange& rhs);
-bool operator!= (const VMRange& lhs, const VMRange& rhs);
-bool operator< (const VMRange& lhs, const VMRange& rhs);
-bool operator<= (const VMRange& lhs, const VMRange& rhs);
-bool operator> (const VMRange& lhs, const VMRange& rhs);
-bool operator>= (const VMRange& lhs, const VMRange& rhs);
+bool operator==(const VMRange &lhs, const VMRange &rhs);
+bool operator!=(const VMRange &lhs, const VMRange &rhs);
+bool operator<(const VMRange &lhs, const VMRange &rhs);
+bool operator<=(const VMRange &lhs, const VMRange &rhs);
+bool operator>(const VMRange &lhs, const VMRange &rhs);
+bool operator>=(const VMRange &lhs, const VMRange &rhs);
} // namespace lldb_private
-#endif // liblldb_VMRange_h_
+#endif // liblldb_VMRange_h_
Modified: lldb/trunk/include/lldb/Core/Value.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Tue Sep 6 15:57:50 2016
@@ -16,308 +16,232 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
-class Value
-{
+class Value {
public:
- // Values Less than zero are an error, greater than or equal to zero
- // returns what the Scalar result is.
- enum ValueType
- {
- // m_value contains...
- // ============================
- eValueTypeScalar, // raw scalar value
- eValueTypeVector, // byte array of m_vector.length with endianness of m_vector.byte_order
- eValueTypeFileAddress, // file address value
- eValueTypeLoadAddress, // load address value
- eValueTypeHostAddress // host address value (for memory in the process that is using liblldb)
- };
-
- enum ContextType // Type that describes Value::m_context
- {
- // m_context contains...
- // ====================
- eContextTypeInvalid, // undefined
- eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector register)
- eContextTypeLLDBType, // lldb_private::Type *
- eContextTypeVariable // lldb_private::Variable *
- };
-
- const static size_t kMaxByteSize = 32u;
-
- struct Vector
- {
- // The byte array must be big enough to hold vector registers for any supported target.
- uint8_t bytes[kMaxByteSize];
- size_t length;
- lldb::ByteOrder byte_order;
-
- Vector() :
- length(0),
- byte_order(lldb::eByteOrderInvalid)
- {
- }
-
- Vector(const Vector& vector)
- { *this = vector;
- }
- const Vector&
- operator=(const Vector& vector)
- {
- SetBytes(vector.bytes, vector.length, vector.byte_order);
- return *this;
- }
-
- void
- Clear ()
- {
- length = 0;
- }
-
- bool
- SetBytes(const void *bytes, size_t length, lldb::ByteOrder byte_order)
- {
- this->length = length;
- this->byte_order = byte_order;
- if (length)
- ::memcpy(this->bytes, bytes, length < kMaxByteSize ? length : kMaxByteSize);
- return IsValid();
- }
-
- bool
- IsValid() const
- {
- return (length > 0 && length < kMaxByteSize && byte_order != lldb::eByteOrderInvalid);
- }
- // Casts a vector, if valid, to an unsigned int of matching or largest supported size.
- // Truncates to the beginning of the vector if required.
- // Returns a default constructed Scalar if the Vector data is internally inconsistent.
- llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)bytes)->x);
- Scalar
- GetAsScalar() const
- {
- Scalar scalar;
- if (IsValid())
- {
- if (length == 1) scalar = *(const uint8_t *)bytes;
- else if (length == 2) scalar = *(const uint16_t *)bytes;
- else if (length == 4) scalar = *(const uint32_t *)bytes;
- else if (length == 8) scalar = *(const uint64_t *)bytes;
- else if (length >= 16) scalar = rhs;
- }
- return scalar;
- }
- };
-
- Value();
- Value(const Scalar& scalar);
- Value(const Vector& vector);
- Value(const void *bytes, int len);
- Value(const Value &rhs);
-
- void
- SetBytes (const void *bytes, int len);
-
- void
- AppendBytes (const void *bytes, int len);
-
- Value &
- operator=(const Value &rhs);
-
- const CompilerType &
- GetCompilerType();
-
- void
- SetCompilerType (const CompilerType &compiler_type);
-
- ValueType
- GetValueType() const;
-
- AddressType
- GetValueAddressType () const;
-
- ContextType
- GetContextType() const
- {
- return m_context_type;
- }
+ // Values Less than zero are an error, greater than or equal to zero
+ // returns what the Scalar result is.
+ enum ValueType {
+ // m_value contains...
+ // ============================
+ eValueTypeScalar, // raw scalar value
+ eValueTypeVector, // byte array of m_vector.length with endianness of
+ // m_vector.byte_order
+ eValueTypeFileAddress, // file address value
+ eValueTypeLoadAddress, // load address value
+ eValueTypeHostAddress // host address value (for memory in the process that
+ // is using liblldb)
+ };
- void
- SetValueType (ValueType value_type)
- {
- m_value_type = value_type;
- }
+ enum ContextType // Type that describes Value::m_context
+ {
+ // m_context contains...
+ // ====================
+ eContextTypeInvalid, // undefined
+ eContextTypeRegisterInfo, // RegisterInfo * (can be a scalar or a vector
+ // register)
+ eContextTypeLLDBType, // lldb_private::Type *
+ eContextTypeVariable // lldb_private::Variable *
+ };
- void
- ClearContext ()
- {
- m_context = nullptr;
- m_context_type = eContextTypeInvalid;
- }
+ const static size_t kMaxByteSize = 32u;
- void
- SetContext (ContextType context_type, void *p)
- {
- m_context_type = context_type;
- m_context = p;
- if (m_context_type == eContextTypeRegisterInfo) {
- RegisterInfo *reg_info = GetRegisterInfo();
- if (reg_info->encoding == lldb::eEncodingVector &&
- m_vector.byte_order != lldb::eByteOrderInvalid)
- SetValueType(eValueTypeScalar);
- }
- }
+ struct Vector {
+ // The byte array must be big enough to hold vector registers for any
+ // supported target.
+ uint8_t bytes[kMaxByteSize];
+ size_t length;
+ lldb::ByteOrder byte_order;
- RegisterInfo *
- GetRegisterInfo() const;
+ Vector() : length(0), byte_order(lldb::eByteOrderInvalid) {}
- Type *
- GetType();
+ Vector(const Vector &vector) { *this = vector; }
+ const Vector &operator=(const Vector &vector) {
+ SetBytes(vector.bytes, vector.length, vector.byte_order);
+ return *this;
+ }
- Scalar &
- ResolveValue (ExecutionContext *exe_ctx);
+ void Clear() { length = 0; }
- const Scalar &
- GetScalar() const
- {
- return m_value;
- }
-
- const Vector &
- GetVector() const
- {
- return m_vector;
- }
-
- Scalar &
- GetScalar()
- {
- return m_value;
- }
-
- Vector &
- GetVector()
- {
- return m_vector;
+ bool SetBytes(const void *bytes, size_t length,
+ lldb::ByteOrder byte_order) {
+ this->length = length;
+ this->byte_order = byte_order;
+ if (length)
+ ::memcpy(this->bytes, bytes,
+ length < kMaxByteSize ? length : kMaxByteSize);
+ return IsValid();
}
- bool
- SetVectorBytes(const Vector& vector)
- {
- m_vector = vector;
- return m_vector.IsValid();
+ bool IsValid() const {
+ return (length > 0 && length < kMaxByteSize &&
+ byte_order != lldb::eByteOrderInvalid);
}
-
- bool
- SetVectorBytes(uint8_t *bytes, size_t length, lldb::ByteOrder byte_order)
- {
- return m_vector.SetBytes(bytes, length, byte_order);
+ // Casts a vector, if valid, to an unsigned int of matching or largest
+ // supported size.
+ // Truncates to the beginning of the vector if required.
+ // Returns a default constructed Scalar if the Vector data is internally
+ // inconsistent.
+ llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ ((type128 *)bytes)->x);
+ Scalar GetAsScalar() const {
+ Scalar scalar;
+ if (IsValid()) {
+ if (length == 1)
+ scalar = *(const uint8_t *)bytes;
+ else if (length == 2)
+ scalar = *(const uint16_t *)bytes;
+ else if (length == 4)
+ scalar = *(const uint32_t *)bytes;
+ else if (length == 8)
+ scalar = *(const uint64_t *)bytes;
+ else if (length >= 16)
+ scalar = rhs;
+ }
+ return scalar;
}
+ };
- bool
- SetScalarFromVector()
- {
- if (m_vector.IsValid())
- {
- m_value = m_vector.GetAsScalar();
- return true;
- }
- return false;
- }
+ Value();
+ Value(const Scalar &scalar);
+ Value(const Vector &vector);
+ Value(const void *bytes, int len);
+ Value(const Value &rhs);
+
+ void SetBytes(const void *bytes, int len);
+
+ void AppendBytes(const void *bytes, int len);
+
+ Value &operator=(const Value &rhs);
+
+ const CompilerType &GetCompilerType();
+
+ void SetCompilerType(const CompilerType &compiler_type);
+
+ ValueType GetValueType() const;
+
+ AddressType GetValueAddressType() const;
- size_t
- ResizeData(size_t len);
-
- size_t
- AppendDataToHostBuffer (const Value &rhs);
-
- DataBufferHeap &
- GetBuffer ()
- {
- return m_data_buffer;
+ ContextType GetContextType() const { return m_context_type; }
+
+ void SetValueType(ValueType value_type) { m_value_type = value_type; }
+
+ void ClearContext() {
+ m_context = nullptr;
+ m_context_type = eContextTypeInvalid;
+ }
+
+ void SetContext(ContextType context_type, void *p) {
+ m_context_type = context_type;
+ m_context = p;
+ if (m_context_type == eContextTypeRegisterInfo) {
+ RegisterInfo *reg_info = GetRegisterInfo();
+ if (reg_info->encoding == lldb::eEncodingVector &&
+ m_vector.byte_order != lldb::eByteOrderInvalid)
+ SetValueType(eValueTypeScalar);
}
+ }
+
+ RegisterInfo *GetRegisterInfo() const;
+
+ Type *GetType();
+
+ Scalar &ResolveValue(ExecutionContext *exe_ctx);
+
+ const Scalar &GetScalar() const { return m_value; }
+
+ const Vector &GetVector() const { return m_vector; }
+
+ Scalar &GetScalar() { return m_value; }
- const DataBufferHeap &
- GetBuffer () const
- {
- return m_data_buffer;
+ Vector &GetVector() { return m_vector; }
+
+ bool SetVectorBytes(const Vector &vector) {
+ m_vector = vector;
+ return m_vector.IsValid();
+ }
+
+ bool SetVectorBytes(uint8_t *bytes, size_t length,
+ lldb::ByteOrder byte_order) {
+ return m_vector.SetBytes(bytes, length, byte_order);
+ }
+
+ bool SetScalarFromVector() {
+ if (m_vector.IsValid()) {
+ m_value = m_vector.GetAsScalar();
+ return true;
}
+ return false;
+ }
+
+ size_t ResizeData(size_t len);
- bool
- ValueOf(ExecutionContext *exe_ctx);
+ size_t AppendDataToHostBuffer(const Value &rhs);
- Variable *
- GetVariable();
+ DataBufferHeap &GetBuffer() { return m_data_buffer; }
- void
- Dump (Stream* strm);
+ const DataBufferHeap &GetBuffer() const { return m_data_buffer; }
- lldb::Format
- GetValueDefaultFormat ();
+ bool ValueOf(ExecutionContext *exe_ctx);
- uint64_t
- GetValueByteSize (Error *error_ptr, ExecutionContext *exe_ctx);
+ Variable *GetVariable();
- Error
- GetValueAsData(ExecutionContext *exe_ctx,
- DataExtractor &data,
- uint32_t data_offset,
- Module *module); // Can be nullptr
+ void Dump(Stream *strm);
- static const char *
- GetValueTypeAsCString (ValueType context_type);
+ lldb::Format GetValueDefaultFormat();
- static const char *
- GetContextTypeAsCString (ContextType context_type);
+ uint64_t GetValueByteSize(Error *error_ptr, ExecutionContext *exe_ctx);
- bool
- GetData (DataExtractor &data);
+ Error GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
+ uint32_t data_offset,
+ Module *module); // Can be nullptr
- void
- Clear();
+ static const char *GetValueTypeAsCString(ValueType context_type);
+
+ static const char *GetContextTypeAsCString(ContextType context_type);
+
+ bool GetData(DataExtractor &data);
+
+ void Clear();
protected:
- Scalar m_value;
- Vector m_vector;
- CompilerType m_compiler_type;
- void * m_context;
- ValueType m_value_type;
- ContextType m_context_type;
- DataBufferHeap m_data_buffer;
+ Scalar m_value;
+ Vector m_vector;
+ CompilerType m_compiler_type;
+ void *m_context;
+ ValueType m_value_type;
+ ContextType m_context_type;
+ DataBufferHeap m_data_buffer;
};
-class ValueList
-{
+class ValueList {
public:
- ValueList () :
- m_values()
- {
- }
+ ValueList() : m_values() {}
- ValueList (const ValueList &rhs);
+ ValueList(const ValueList &rhs);
- ~ValueList() = default;
+ ~ValueList() = default;
- const ValueList & operator= (const ValueList &rhs);
+ const ValueList &operator=(const ValueList &rhs);
- // void InsertValue (Value *value, size_t idx);
- void PushValue (const Value &value);
+ // void InsertValue (Value *value, size_t idx);
+ void PushValue(const Value &value);
- size_t GetSize ();
- Value *GetValueAtIndex(size_t idx);
- void Clear();
+ size_t GetSize();
+ Value *GetValueAtIndex(size_t idx);
+ void Clear();
private:
- typedef std::vector<Value> collection;
+ typedef std::vector<Value> collection;
- collection m_values;
+ collection m_values;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Sep 6 15:57:50 2016
@@ -22,11 +22,10 @@
#include "llvm/ADT/SmallVector.h"
// Project includes
-#include "lldb/lldb-private.h"
+#include "lldb/Core/ConstString.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/Flags.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/Value.h"
#include "lldb/Symbol/CompilerType.h"
@@ -35,1261 +34,1001 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/StackID.h"
#include "lldb/Utility/SharedCluster.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
/// ValueObject:
///
-/// This abstract class provides an interface to a particular value, be it a register, a local or global variable,
-/// that is evaluated in some particular scope. The ValueObject also has the capability of being the "child" of
-/// some other variable object, and in turn of having children.
-/// If a ValueObject is a root variable object - having no parent - then it must be constructed with respect to some
-/// particular ExecutionContextScope. If it is a child, it inherits the ExecutionContextScope from its parent.
-/// The ValueObject will update itself if necessary before fetching its value, summary, object description, etc.
-/// But it will always update itself in the ExecutionContextScope with which it was originally created.
-
-/// A brief note on life cycle management for ValueObjects. This is a little tricky because a ValueObject can contain
-/// various other ValueObjects - the Dynamic Value, its children, the dereference value, etc. Any one of these can be
-/// handed out as a shared pointer, but for that contained value object to be valid, the root object and potentially other
-/// of the value objects need to stay around.
-/// We solve this problem by handing out shared pointers to the Value Object and any of its dependents using a shared
-/// ClusterManager. This treats each shared pointer handed out for the entire cluster as a reference to the whole
-/// cluster. The whole cluster will stay around until the last reference is released.
+/// This abstract class provides an interface to a particular value, be it a
+/// register, a local or global variable,
+/// that is evaluated in some particular scope. The ValueObject also has the
+/// capability of being the "child" of
+/// some other variable object, and in turn of having children.
+/// If a ValueObject is a root variable object - having no parent - then it must
+/// be constructed with respect to some
+/// particular ExecutionContextScope. If it is a child, it inherits the
+/// ExecutionContextScope from its parent.
+/// The ValueObject will update itself if necessary before fetching its value,
+/// summary, object description, etc.
+/// But it will always update itself in the ExecutionContextScope with which it
+/// was originally created.
+
+/// A brief note on life cycle management for ValueObjects. This is a little
+/// tricky because a ValueObject can contain
+/// various other ValueObjects - the Dynamic Value, its children, the
+/// dereference value, etc. Any one of these can be
+/// handed out as a shared pointer, but for that contained value object to be
+/// valid, the root object and potentially other
+/// of the value objects need to stay around.
+/// We solve this problem by handing out shared pointers to the Value Object and
+/// any of its dependents using a shared
+/// ClusterManager. This treats each shared pointer handed out for the entire
+/// cluster as a reference to the whole
+/// cluster. The whole cluster will stay around until the last reference is
+/// released.
///
-/// The ValueObject mostly handle this automatically, if a value object is made with a Parent ValueObject, then it adds
+/// The ValueObject mostly handle this automatically, if a value object is made
+/// with a Parent ValueObject, then it adds
/// itself to the ClusterManager of the parent.
-/// It does mean that external to the ValueObjects we should only ever make available ValueObjectSP's, never ValueObjects
-/// or pointers to them. So all the "Root level" ValueObject derived constructors should be private, and
-/// should implement a Create function that new's up object and returns a Shared Pointer that it gets from the GetSP() method.
+/// It does mean that external to the ValueObjects we should only ever make
+/// available ValueObjectSP's, never ValueObjects
+/// or pointers to them. So all the "Root level" ValueObject derived
+/// constructors should be private, and
+/// should implement a Create function that new's up object and returns a Shared
+/// Pointer that it gets from the GetSP() method.
///
-/// However, if you are making an derived ValueObject that will be contained in a parent value object, you should just
-/// hold onto a pointer to it internally, and by virtue of passing the parent ValueObject into its constructor, it will
-/// be added to the ClusterManager for the parent. Then if you ever hand out a Shared Pointer to the contained ValueObject,
+/// However, if you are making an derived ValueObject that will be contained in
+/// a parent value object, you should just
+/// hold onto a pointer to it internally, and by virtue of passing the parent
+/// ValueObject into its constructor, it will
+/// be added to the ClusterManager for the parent. Then if you ever hand out a
+/// Shared Pointer to the contained ValueObject,
/// just do so by calling GetSP() on the contained object.
-class ValueObject : public UserID
-{
+class ValueObject : public UserID {
public:
- enum GetExpressionPathFormat
- {
- eGetExpressionPathFormatDereferencePointers = 1,
- eGetExpressionPathFormatHonorPointers
- };
-
- enum ValueObjectRepresentationStyle
- {
- eValueObjectRepresentationStyleValue = 1,
- eValueObjectRepresentationStyleSummary,
- eValueObjectRepresentationStyleLanguageSpecific,
- eValueObjectRepresentationStyleLocation,
- eValueObjectRepresentationStyleChildrenCount,
- eValueObjectRepresentationStyleType,
- eValueObjectRepresentationStyleName,
- eValueObjectRepresentationStyleExpressionPath
- };
-
- enum ExpressionPathScanEndReason
- {
- eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
- eExpressionPathScanEndReasonNoSuchChild, // child element not found
- eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child element not found
- eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for arrays
- eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be used
- eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be used
- eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion not allowed
- eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by options
- eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects other than scalars, pointers or arrays
- eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays, but I cannot parse it
- eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for bitfields, but I cannot parse after it
- eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in the expression
- eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply & operator
- eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply * operator
- eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a VOList
- eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic children failed
- eExpressionPathScanEndReasonUnknown = 0xFFFF
- };
-
- enum ExpressionPathEndResultType
- {
- eExpressionPathEndResultTypePlain = 1, // anything but...
- eExpressionPathEndResultTypeBitfield, // a bitfield
- eExpressionPathEndResultTypeBoundedRange, // a range [low-high]
- eExpressionPathEndResultTypeUnboundedRange, // a range []
- eExpressionPathEndResultTypeValueObjectList, // several items in a VOList
- eExpressionPathEndResultTypeInvalid = 0xFFFF
- };
-
- enum ExpressionPathAftermath
- {
- eExpressionPathAftermathNothing = 1, // just return it
- eExpressionPathAftermathDereference, // dereference the target
- eExpressionPathAftermathTakeAddress // take target's address
- };
-
- enum ClearUserVisibleDataItems
- {
- eClearUserVisibleDataItemsNothing = 1u << 0,
- eClearUserVisibleDataItemsValue = 1u << 1,
- eClearUserVisibleDataItemsSummary = 1u << 2,
- eClearUserVisibleDataItemsLocation = 1u << 3,
- eClearUserVisibleDataItemsDescription = 1u << 4,
- eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
- eClearUserVisibleDataItemsValidator = 1u << 6,
- eClearUserVisibleDataItemsAllStrings = eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | eClearUserVisibleDataItemsLocation | eClearUserVisibleDataItemsDescription,
- eClearUserVisibleDataItemsAll = 0xFFFF
- };
-
- struct GetValueForExpressionPathOptions
- {
- enum class SyntheticChildrenTraversal
- {
- None,
- ToSynthetic,
- FromSynthetic,
- Both
- };
-
- bool m_check_dot_vs_arrow_syntax;
- bool m_no_fragile_ivar;
- bool m_allow_bitfields_syntax;
- SyntheticChildrenTraversal m_synthetic_children_traversal;
-
- GetValueForExpressionPathOptions(bool dot = false,
- bool no_ivar = false,
- bool bitfield = true,
- SyntheticChildrenTraversal synth_traverse = SyntheticChildrenTraversal::ToSynthetic) :
- m_check_dot_vs_arrow_syntax(dot),
- m_no_fragile_ivar(no_ivar),
- m_allow_bitfields_syntax(bitfield),
- m_synthetic_children_traversal(synth_traverse)
- {
- }
-
- GetValueForExpressionPathOptions&
- DoCheckDotVsArrowSyntax()
- {
- m_check_dot_vs_arrow_syntax = true;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DontCheckDotVsArrowSyntax()
- {
- m_check_dot_vs_arrow_syntax = false;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DoAllowFragileIVar()
- {
- m_no_fragile_ivar = false;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DontAllowFragileIVar()
- {
- m_no_fragile_ivar = true;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DoAllowBitfieldSyntax()
- {
- m_allow_bitfields_syntax = true;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- DontAllowBitfieldSyntax()
- {
- m_allow_bitfields_syntax = false;
- return *this;
- }
-
- GetValueForExpressionPathOptions&
- SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
- {
- m_synthetic_children_traversal = traverse;
- return *this;
- }
-
- static const GetValueForExpressionPathOptions
- DefaultOptions()
- {
- static GetValueForExpressionPathOptions g_default_options;
-
- return g_default_options;
- }
+ enum GetExpressionPathFormat {
+ eGetExpressionPathFormatDereferencePointers = 1,
+ eGetExpressionPathFormatHonorPointers
+ };
+
+ enum ValueObjectRepresentationStyle {
+ eValueObjectRepresentationStyleValue = 1,
+ eValueObjectRepresentationStyleSummary,
+ eValueObjectRepresentationStyleLanguageSpecific,
+ eValueObjectRepresentationStyleLocation,
+ eValueObjectRepresentationStyleChildrenCount,
+ eValueObjectRepresentationStyleType,
+ eValueObjectRepresentationStyleName,
+ eValueObjectRepresentationStyleExpressionPath
+ };
+
+ enum ExpressionPathScanEndReason {
+ eExpressionPathScanEndReasonEndOfString = 1, // out of data to parse
+ eExpressionPathScanEndReasonNoSuchChild, // child element not found
+ eExpressionPathScanEndReasonNoSuchSyntheticChild, // (synthetic) child
+ // element not found
+ eExpressionPathScanEndReasonEmptyRangeNotAllowed, // [] only allowed for
+ // arrays
+ eExpressionPathScanEndReasonDotInsteadOfArrow, // . used when -> should be
+ // used
+ eExpressionPathScanEndReasonArrowInsteadOfDot, // -> used when . should be
+ // used
+ eExpressionPathScanEndReasonFragileIVarNotAllowed, // ObjC ivar expansion
+ // not allowed
+ eExpressionPathScanEndReasonRangeOperatorNotAllowed, // [] not allowed by
+ // options
+ eExpressionPathScanEndReasonRangeOperatorInvalid, // [] not valid on objects
+ // other than scalars,
+ // pointers or arrays
+ eExpressionPathScanEndReasonArrayRangeOperatorMet, // [] is good for arrays,
+ // but I cannot parse it
+ eExpressionPathScanEndReasonBitfieldRangeOperatorMet, // [] is good for
+ // bitfields, but I
+ // cannot parse after
+ // it
+ eExpressionPathScanEndReasonUnexpectedSymbol, // something is malformed in
+ // the expression
+ eExpressionPathScanEndReasonTakingAddressFailed, // impossible to apply &
+ // operator
+ eExpressionPathScanEndReasonDereferencingFailed, // impossible to apply *
+ // operator
+ eExpressionPathScanEndReasonRangeOperatorExpanded, // [] was expanded into a
+ // VOList
+ eExpressionPathScanEndReasonSyntheticValueMissing, // getting the synthetic
+ // children failed
+ eExpressionPathScanEndReasonUnknown = 0xFFFF
+ };
+
+ enum ExpressionPathEndResultType {
+ eExpressionPathEndResultTypePlain = 1, // anything but...
+ eExpressionPathEndResultTypeBitfield, // a bitfield
+ eExpressionPathEndResultTypeBoundedRange, // a range [low-high]
+ eExpressionPathEndResultTypeUnboundedRange, // a range []
+ eExpressionPathEndResultTypeValueObjectList, // several items in a VOList
+ eExpressionPathEndResultTypeInvalid = 0xFFFF
+ };
+
+ enum ExpressionPathAftermath {
+ eExpressionPathAftermathNothing = 1, // just return it
+ eExpressionPathAftermathDereference, // dereference the target
+ eExpressionPathAftermathTakeAddress // take target's address
+ };
+
+ enum ClearUserVisibleDataItems {
+ eClearUserVisibleDataItemsNothing = 1u << 0,
+ eClearUserVisibleDataItemsValue = 1u << 1,
+ eClearUserVisibleDataItemsSummary = 1u << 2,
+ eClearUserVisibleDataItemsLocation = 1u << 3,
+ eClearUserVisibleDataItemsDescription = 1u << 4,
+ eClearUserVisibleDataItemsSyntheticChildren = 1u << 5,
+ eClearUserVisibleDataItemsValidator = 1u << 6,
+ eClearUserVisibleDataItemsAllStrings =
+ eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary |
+ eClearUserVisibleDataItemsLocation |
+ eClearUserVisibleDataItemsDescription,
+ eClearUserVisibleDataItemsAll = 0xFFFF
+ };
+
+ struct GetValueForExpressionPathOptions {
+ enum class SyntheticChildrenTraversal {
+ None,
+ ToSynthetic,
+ FromSynthetic,
+ Both
};
- class EvaluationPoint
- {
- public:
- EvaluationPoint ();
-
- EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected = false);
-
- EvaluationPoint (const EvaluationPoint &rhs);
-
- ~EvaluationPoint ();
-
- const ExecutionContextRef &
- GetExecutionContextRef() const
- {
- return m_exe_ctx_ref;
- }
-
- // Set the EvaluationPoint to the values in exe_scope,
- // Return true if the Evaluation Point changed.
- // Since the ExecutionContextScope is always going to be valid currently,
- // the Updated Context will also always be valid.
-
-// bool
-// SetContext (ExecutionContextScope *exe_scope);
-
- void
- SetIsConstant ()
- {
- SetUpdated();
- m_mod_id.SetInvalid();
- }
-
- bool
- IsConstant () const
- {
- return !m_mod_id.IsValid();
- }
-
- ProcessModID
- GetModID () const
- {
- return m_mod_id;
- }
-
- void
- SetUpdateID (ProcessModID new_id)
- {
- m_mod_id = new_id;
- }
-
- void
- SetNeedsUpdate ()
- {
- m_needs_update = true;
- }
-
- void
- SetUpdated ();
-
- bool
- NeedsUpdating(bool accept_invalid_exe_ctx)
- {
- SyncWithProcessState(accept_invalid_exe_ctx);
- return m_needs_update;
- }
-
- bool
- IsValid ()
- {
- const bool accept_invalid_exe_ctx = false;
- if (!m_mod_id.IsValid())
- return false;
- else if (SyncWithProcessState (accept_invalid_exe_ctx))
- {
- if (!m_mod_id.IsValid())
- return false;
- }
- return true;
- }
-
- void
- SetInvalid ()
- {
- // Use the stop id to mark us as invalid, leave the thread id and the stack id around for logging and
- // history purposes.
- m_mod_id.SetInvalid();
-
- // Can't update an invalid state.
- m_needs_update = false;
-
- }
-
- private:
- bool
- SyncWithProcessState (bool accept_invalid_exe_ctx);
-
- ProcessModID m_mod_id; // This is the stop id when this ValueObject was last evaluated.
- ExecutionContextRef m_exe_ctx_ref;
- bool m_needs_update;
- };
+ bool m_check_dot_vs_arrow_syntax;
+ bool m_no_fragile_ivar;
+ bool m_allow_bitfields_syntax;
+ SyntheticChildrenTraversal m_synthetic_children_traversal;
- virtual ~ValueObject();
+ GetValueForExpressionPathOptions(
+ bool dot = false, bool no_ivar = false, bool bitfield = true,
+ SyntheticChildrenTraversal synth_traverse =
+ SyntheticChildrenTraversal::ToSynthetic)
+ : m_check_dot_vs_arrow_syntax(dot), m_no_fragile_ivar(no_ivar),
+ m_allow_bitfields_syntax(bitfield),
+ m_synthetic_children_traversal(synth_traverse) {}
- const EvaluationPoint &
- GetUpdatePoint () const
- {
- return m_update_point;
- }
-
- EvaluationPoint &
- GetUpdatePoint ()
- {
- return m_update_point;
- }
-
- const ExecutionContextRef &
- GetExecutionContextRef() const
- {
- return m_update_point.GetExecutionContextRef();
+ GetValueForExpressionPathOptions &DoCheckDotVsArrowSyntax() {
+ m_check_dot_vs_arrow_syntax = true;
+ return *this;
}
- lldb::TargetSP
- GetTargetSP() const
- {
- return m_update_point.GetExecutionContextRef().GetTargetSP();
+ GetValueForExpressionPathOptions &DontCheckDotVsArrowSyntax() {
+ m_check_dot_vs_arrow_syntax = false;
+ return *this;
}
- lldb::ProcessSP
- GetProcessSP() const
- {
- return m_update_point.GetExecutionContextRef().GetProcessSP();
+ GetValueForExpressionPathOptions &DoAllowFragileIVar() {
+ m_no_fragile_ivar = false;
+ return *this;
}
- lldb::ThreadSP
- GetThreadSP() const
- {
- return m_update_point.GetExecutionContextRef().GetThreadSP();
+ GetValueForExpressionPathOptions &DontAllowFragileIVar() {
+ m_no_fragile_ivar = true;
+ return *this;
}
- lldb::StackFrameSP
- GetFrameSP() const
- {
- return m_update_point.GetExecutionContextRef().GetFrameSP();
+ GetValueForExpressionPathOptions &DoAllowBitfieldSyntax() {
+ m_allow_bitfields_syntax = true;
+ return *this;
}
- void
- SetNeedsUpdate ();
-
- CompilerType
- GetCompilerType ();
-
- // this vends a TypeImpl that is useful at the SB API layer
- virtual TypeImpl
- GetTypeImpl ();
-
- virtual bool
- CanProvideValue ();
-
- //------------------------------------------------------------------
- // Subclasses must implement the functions below.
- //------------------------------------------------------------------
- virtual uint64_t
- GetByteSize() = 0;
-
- virtual lldb::ValueType
- GetValueType() const = 0;
-
- //------------------------------------------------------------------
- // Subclasses can implement the functions below.
- //------------------------------------------------------------------
- virtual ConstString
- GetTypeName();
-
- virtual ConstString
- GetDisplayTypeName();
-
- virtual ConstString
- GetQualifiedTypeName();
-
- virtual lldb::LanguageType
- GetObjectRuntimeLanguage();
-
- virtual uint32_t
- GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr);
-
- virtual bool
- IsPointerType ();
-
- virtual bool
- IsArrayType ();
-
- virtual bool
- IsScalarType ();
-
- virtual bool
- IsPointerOrReferenceType ();
-
- virtual bool
- IsPossibleDynamicType ();
-
- bool
- IsNilReference ();
-
- bool
- IsUninitializedReference ();
-
- virtual bool
- IsBaseClass ()
- {
- return false;
- }
-
- bool
- IsBaseClass (uint32_t& depth);
-
- virtual bool
- IsDereferenceOfParent ()
- {
- return false;
- }
-
- bool
- IsIntegerType (bool &is_signed);
-
- virtual bool
- GetBaseClassPath (Stream &s);
-
- virtual void
- GetExpressionPath (Stream &s, bool qualify_cxx_base_classes, GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
-
- lldb::ValueObjectSP
- GetValueForExpressionPath(const char* expression,
- const char** first_unparsed = nullptr,
- ExpressionPathScanEndReason* reason_to_stop = nullptr,
- ExpressionPathEndResultType* final_value_type = nullptr,
- const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
- ExpressionPathAftermath* final_task_on_target = nullptr);
-
- int
- GetValuesForExpressionPath(const char* expression,
- lldb::ValueObjectListSP& list,
- const char** first_unparsed = nullptr,
- ExpressionPathScanEndReason* reason_to_stop = nullptr,
- ExpressionPathEndResultType* final_value_type = nullptr,
- const GetValueForExpressionPathOptions& options = GetValueForExpressionPathOptions::DefaultOptions(),
- ExpressionPathAftermath* final_task_on_target = nullptr);
-
- virtual bool
- IsInScope ()
- {
- return true;
+ GetValueForExpressionPathOptions &DontAllowBitfieldSyntax() {
+ m_allow_bitfields_syntax = false;
+ return *this;
}
- virtual lldb::offset_t
- GetByteOffset()
- {
- return 0;
+ GetValueForExpressionPathOptions &
+ SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse) {
+ m_synthetic_children_traversal = traverse;
+ return *this;
}
- virtual uint32_t
- GetBitfieldBitSize ()
- {
- return 0;
- }
+ static const GetValueForExpressionPathOptions DefaultOptions() {
+ static GetValueForExpressionPathOptions g_default_options;
- virtual uint32_t
- GetBitfieldBitOffset ()
- {
- return 0;
- }
-
- bool
- IsBitfield ()
- {
- return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
- }
-
- virtual bool
- IsArrayItemForPointer()
- {
- return m_is_array_item_for_pointer;
+ return g_default_options;
}
-
- virtual const char *
- GetValueAsCString ();
-
- virtual bool
- GetValueAsCString (const lldb_private::TypeFormatImpl& format,
- std::string& destination);
-
- bool
- GetValueAsCString (lldb::Format format,
- std::string& destination);
-
- virtual uint64_t
- GetValueAsUnsigned(uint64_t fail_value, bool *success = nullptr);
-
- virtual int64_t
- GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
-
- virtual bool
- SetValueFromCString (const char *value_str, Error& error);
-
- // Return the module associated with this value object in case the
- // value is from an executable file and might have its data in
- // sections of the file. This can be used for variables.
- virtual lldb::ModuleSP
- GetModule();
-
- ValueObject*
- GetRoot ();
-
- // Given a ValueObject, loop over itself and its parent, and its parent's parent, ..
- // until either the given callback returns false, or you end up at a null pointer
- ValueObject*
- FollowParentChain (std::function<bool(ValueObject*)>);
-
- virtual bool
- GetDeclaration (Declaration &decl);
-
- //------------------------------------------------------------------
- // The functions below should NOT be modified by subclasses
- //------------------------------------------------------------------
- const Error &
- GetError();
-
- const ConstString &
- GetName() const;
-
- virtual lldb::ValueObjectSP
- GetChildAtIndex (size_t idx, bool can_create);
-
- // this will always create the children if necessary
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
- size_t* index_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::vector<size_t> &idxs,
- size_t* index_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::initializer_list< std::pair<size_t, bool> > &idxs,
- size_t* index_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtIndexPath(const std::vector< std::pair<size_t, bool> > &idxs,
- size_t* index_of_error = nullptr);
-
- // this will always create the children if necessary
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::initializer_list<ConstString> &names,
- ConstString* name_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::vector<ConstString> &names,
- ConstString* name_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::initializer_list< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error = nullptr);
-
- lldb::ValueObjectSP
- GetChildAtNamePath(const std::vector< std::pair<ConstString, bool> > &names,
- ConstString* name_of_error = nullptr);
-
- virtual lldb::ValueObjectSP
- GetChildMemberWithName (const ConstString &name, bool can_create);
-
- virtual size_t
- GetIndexOfChildWithName (const ConstString &name);
-
- size_t
- GetNumChildren (uint32_t max=UINT32_MAX);
-
- const Value &
- GetValue() const;
-
- Value &
- GetValue();
-
- virtual bool
- ResolveValue (Scalar &scalar);
-
- // return 'false' whenever you set the error, otherwise
- // callers may assume true means everything is OK - this will
- // break breakpoint conditions among potentially a few others
- virtual bool
- IsLogicalTrue (Error& error);
-
- virtual const char *
- GetLocationAsCString ();
-
- const char *
- GetSummaryAsCString (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
-
- bool
- GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
- std::string& destination,
- lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
-
- bool
- GetSummaryAsCString (std::string& destination,
- const TypeSummaryOptions& options);
-
- bool
- GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
- std::string& destination,
- const TypeSummaryOptions& options);
-
- std::pair<TypeValidatorResult, std::string>
- GetValidationStatus ();
-
- const char *
- GetObjectDescription ();
-
- bool
- HasSpecialPrintableRepresentation (ValueObjectRepresentationStyle val_obj_display,
- lldb::Format custom_format);
-
- enum PrintableRepresentationSpecialCases
- {
- ePrintableRepresentationSpecialCasesDisable = 0,
- ePrintableRepresentationSpecialCasesAllow = 1,
- ePrintableRepresentationSpecialCasesOnly = 3
- };
-
- bool
- DumpPrintableRepresentation (Stream& s,
- ValueObjectRepresentationStyle val_obj_display = eValueObjectRepresentationStyleSummary,
- lldb::Format custom_format = lldb::eFormatInvalid,
- PrintableRepresentationSpecialCases special = ePrintableRepresentationSpecialCasesAllow,
- bool do_dump_error = true);
- bool
- GetValueIsValid () const;
-
- // If you call this on a newly created ValueObject, it will always return false.
- bool
- GetValueDidChange ();
-
- bool
- UpdateValueIfNeeded (bool update_format = true);
-
- bool
- UpdateFormatsIfNeeded();
+ };
- lldb::ValueObjectSP
- GetSP ()
- {
- return m_manager->GetSharedPointer(this);
- }
-
- void
- SetName (const ConstString &name);
-
- virtual lldb::addr_t
- GetAddressOf(bool scalar_is_load_address = true,
- AddressType *address_type = nullptr);
-
- lldb::addr_t
- GetPointerValue(AddressType *address_type = nullptr);
-
- lldb::ValueObjectSP
- GetSyntheticChild (const ConstString &key) const;
-
- lldb::ValueObjectSP
- GetSyntheticArrayMember (size_t index, bool can_create);
-
- lldb::ValueObjectSP
- GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
-
- lldb::ValueObjectSP
- GetSyntheticExpressionPathChild(const char* expression, bool can_create);
-
- virtual lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString());
-
- virtual lldb::ValueObjectSP
- GetSyntheticBase (uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString());
-
- virtual lldb::ValueObjectSP
- GetDynamicValue (lldb::DynamicValueType valueType);
-
- lldb::DynamicValueType
- GetDynamicValueType ();
-
- virtual lldb::ValueObjectSP
- GetStaticValue ();
-
- virtual lldb::ValueObjectSP
- GetNonSyntheticValue ();
-
- lldb::ValueObjectSP
- GetSyntheticValue (bool use_synthetic = true);
-
- virtual bool
- HasSyntheticValue();
-
- virtual bool
- IsSynthetic() { return false; }
-
- lldb::ValueObjectSP
- GetQualifiedRepresentationIfAvailable (lldb::DynamicValueType dynValue,
- bool synthValue);
-
- virtual lldb::ValueObjectSP
- CreateConstantValue (const ConstString &name);
-
- virtual lldb::ValueObjectSP
- Dereference (Error &error);
-
- virtual lldb::ValueObjectSP
- AddressOf (Error &error);
-
- virtual lldb::addr_t
- GetLiveAddress()
- {
- return LLDB_INVALID_ADDRESS;
+ class EvaluationPoint {
+ public:
+ EvaluationPoint();
+
+ EvaluationPoint(ExecutionContextScope *exe_scope,
+ bool use_selected = false);
+
+ EvaluationPoint(const EvaluationPoint &rhs);
+
+ ~EvaluationPoint();
+
+ const ExecutionContextRef &GetExecutionContextRef() const {
+ return m_exe_ctx_ref;
}
-
- virtual void
- SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad)
- {
+
+ // Set the EvaluationPoint to the values in exe_scope,
+ // Return true if the Evaluation Point changed.
+ // Since the ExecutionContextScope is always going to be valid currently,
+ // the Updated Context will also always be valid.
+
+ // bool
+ // SetContext (ExecutionContextScope *exe_scope);
+
+ void SetIsConstant() {
+ SetUpdated();
+ m_mod_id.SetInvalid();
}
- // Find the address of the C++ vtable pointer
- virtual lldb::addr_t
- GetCPPVTableAddress(AddressType &address_type);
-
- virtual lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type);
-
- virtual lldb::ValueObjectSP
- CastPointerType (const char *name,
- CompilerType &ast_type);
-
- virtual lldb::ValueObjectSP
- CastPointerType (const char *name,
- lldb::TypeSP &type_sp);
-
- // The backing bits of this value object were updated, clear any
- // descriptive string, so we know we have to refetch them
- virtual void
- ValueUpdated ()
- {
- ClearUserVisibleData(eClearUserVisibleDataItemsValue |
- eClearUserVisibleDataItemsSummary |
- eClearUserVisibleDataItemsDescription);
+ bool IsConstant() const { return !m_mod_id.IsValid(); }
+
+ ProcessModID GetModID() const { return m_mod_id; }
+
+ void SetUpdateID(ProcessModID new_id) { m_mod_id = new_id; }
+
+ void SetNeedsUpdate() { m_needs_update = true; }
+
+ void SetUpdated();
+
+ bool NeedsUpdating(bool accept_invalid_exe_ctx) {
+ SyncWithProcessState(accept_invalid_exe_ctx);
+ return m_needs_update;
}
- virtual bool
- IsDynamic ()
- {
+ bool IsValid() {
+ const bool accept_invalid_exe_ctx = false;
+ if (!m_mod_id.IsValid())
return false;
+ else if (SyncWithProcessState(accept_invalid_exe_ctx)) {
+ if (!m_mod_id.IsValid())
+ return false;
+ }
+ return true;
}
-
- virtual bool
- DoesProvideSyntheticValue ()
- {
- return false;
+
+ void SetInvalid() {
+ // Use the stop id to mark us as invalid, leave the thread id and the
+ // stack id around for logging and
+ // history purposes.
+ m_mod_id.SetInvalid();
+
+ // Can't update an invalid state.
+ m_needs_update = false;
}
-
- virtual bool
- IsSyntheticChildrenGenerated ();
-
- virtual void
- SetSyntheticChildrenGenerated (bool b);
-
- virtual SymbolContextScope *
- GetSymbolContextScope();
-
- void
- Dump (Stream &s);
-
- void
- Dump (Stream &s,
- const DumpValueObjectOptions& options);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromExpression (const char* name,
- const char* expression,
- const ExecutionContext& exe_ctx);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromExpression (const char* name,
- const char* expression,
- const ExecutionContext& exe_ctx,
- const EvaluateExpressionOptions& options);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromAddress (const char* name,
- uint64_t address,
- const ExecutionContext& exe_ctx,
- CompilerType type);
-
- static lldb::ValueObjectSP
- CreateValueObjectFromData (const char* name,
- const DataExtractor& data,
- const ExecutionContext& exe_ctx,
+
+ private:
+ bool SyncWithProcessState(bool accept_invalid_exe_ctx);
+
+ ProcessModID m_mod_id; // This is the stop id when this ValueObject was last
+ // evaluated.
+ ExecutionContextRef m_exe_ctx_ref;
+ bool m_needs_update;
+ };
+
+ virtual ~ValueObject();
+
+ const EvaluationPoint &GetUpdatePoint() const { return m_update_point; }
+
+ EvaluationPoint &GetUpdatePoint() { return m_update_point; }
+
+ const ExecutionContextRef &GetExecutionContextRef() const {
+ return m_update_point.GetExecutionContextRef();
+ }
+
+ lldb::TargetSP GetTargetSP() const {
+ return m_update_point.GetExecutionContextRef().GetTargetSP();
+ }
+
+ lldb::ProcessSP GetProcessSP() const {
+ return m_update_point.GetExecutionContextRef().GetProcessSP();
+ }
+
+ lldb::ThreadSP GetThreadSP() const {
+ return m_update_point.GetExecutionContextRef().GetThreadSP();
+ }
+
+ lldb::StackFrameSP GetFrameSP() const {
+ return m_update_point.GetExecutionContextRef().GetFrameSP();
+ }
+
+ void SetNeedsUpdate();
+
+ CompilerType GetCompilerType();
+
+ // this vends a TypeImpl that is useful at the SB API layer
+ virtual TypeImpl GetTypeImpl();
+
+ virtual bool CanProvideValue();
+
+ //------------------------------------------------------------------
+ // Subclasses must implement the functions below.
+ //------------------------------------------------------------------
+ virtual uint64_t GetByteSize() = 0;
+
+ virtual lldb::ValueType GetValueType() const = 0;
+
+ //------------------------------------------------------------------
+ // Subclasses can implement the functions below.
+ //------------------------------------------------------------------
+ virtual ConstString GetTypeName();
+
+ virtual ConstString GetDisplayTypeName();
+
+ virtual ConstString GetQualifiedTypeName();
+
+ virtual lldb::LanguageType GetObjectRuntimeLanguage();
+
+ virtual uint32_t
+ GetTypeInfo(CompilerType *pointee_or_element_compiler_type = nullptr);
+
+ virtual bool IsPointerType();
+
+ virtual bool IsArrayType();
+
+ virtual bool IsScalarType();
+
+ virtual bool IsPointerOrReferenceType();
+
+ virtual bool IsPossibleDynamicType();
+
+ bool IsNilReference();
+
+ bool IsUninitializedReference();
+
+ virtual bool IsBaseClass() { return false; }
+
+ bool IsBaseClass(uint32_t &depth);
+
+ virtual bool IsDereferenceOfParent() { return false; }
+
+ bool IsIntegerType(bool &is_signed);
+
+ virtual bool GetBaseClassPath(Stream &s);
+
+ virtual void GetExpressionPath(
+ Stream &s, bool qualify_cxx_base_classes,
+ GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
+
+ lldb::ValueObjectSP GetValueForExpressionPath(
+ const char *expression, const char **first_unparsed = nullptr,
+ ExpressionPathScanEndReason *reason_to_stop = nullptr,
+ ExpressionPathEndResultType *final_value_type = nullptr,
+ const GetValueForExpressionPathOptions &options =
+ GetValueForExpressionPathOptions::DefaultOptions(),
+ ExpressionPathAftermath *final_task_on_target = nullptr);
+
+ int GetValuesForExpressionPath(
+ const char *expression, lldb::ValueObjectListSP &list,
+ const char **first_unparsed = nullptr,
+ ExpressionPathScanEndReason *reason_to_stop = nullptr,
+ ExpressionPathEndResultType *final_value_type = nullptr,
+ const GetValueForExpressionPathOptions &options =
+ GetValueForExpressionPathOptions::DefaultOptions(),
+ ExpressionPathAftermath *final_task_on_target = nullptr);
+
+ virtual bool IsInScope() { return true; }
+
+ virtual lldb::offset_t GetByteOffset() { return 0; }
+
+ virtual uint32_t GetBitfieldBitSize() { return 0; }
+
+ virtual uint32_t GetBitfieldBitOffset() { return 0; }
+
+ bool IsBitfield() {
+ return (GetBitfieldBitSize() != 0) || (GetBitfieldBitOffset() != 0);
+ }
+
+ virtual bool IsArrayItemForPointer() { return m_is_array_item_for_pointer; }
+
+ virtual const char *GetValueAsCString();
+
+ virtual bool GetValueAsCString(const lldb_private::TypeFormatImpl &format,
+ std::string &destination);
+
+ bool GetValueAsCString(lldb::Format format, std::string &destination);
+
+ virtual uint64_t GetValueAsUnsigned(uint64_t fail_value,
+ bool *success = nullptr);
+
+ virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr);
+
+ virtual bool SetValueFromCString(const char *value_str, Error &error);
+
+ // Return the module associated with this value object in case the
+ // value is from an executable file and might have its data in
+ // sections of the file. This can be used for variables.
+ virtual lldb::ModuleSP GetModule();
+
+ ValueObject *GetRoot();
+
+ // Given a ValueObject, loop over itself and its parent, and its parent's
+ // parent, ..
+ // until either the given callback returns false, or you end up at a null
+ // pointer
+ ValueObject *FollowParentChain(std::function<bool(ValueObject *)>);
+
+ virtual bool GetDeclaration(Declaration &decl);
+
+ //------------------------------------------------------------------
+ // The functions below should NOT be modified by subclasses
+ //------------------------------------------------------------------
+ const Error &GetError();
+
+ const ConstString &GetName() const;
+
+ virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create);
+
+ // this will always create the children if necessary
+ lldb::ValueObjectSP
+ GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
+ size_t *index_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtIndexPath(const std::vector<size_t> &idxs,
+ size_t *index_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtIndexPath(
+ const std::initializer_list<std::pair<size_t, bool>> &idxs,
+ size_t *index_of_error = nullptr);
+
+ lldb::ValueObjectSP
+ GetChildAtIndexPath(const std::vector<std::pair<size_t, bool>> &idxs,
+ size_t *index_of_error = nullptr);
+
+ // this will always create the children if necessary
+ lldb::ValueObjectSP
+ GetChildAtNamePath(const std::initializer_list<ConstString> &names,
+ ConstString *name_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtNamePath(const std::vector<ConstString> &names,
+ ConstString *name_of_error = nullptr);
+
+ lldb::ValueObjectSP GetChildAtNamePath(
+ const std::initializer_list<std::pair<ConstString, bool>> &names,
+ ConstString *name_of_error = nullptr);
+
+ lldb::ValueObjectSP
+ GetChildAtNamePath(const std::vector<std::pair<ConstString, bool>> &names,
+ ConstString *name_of_error = nullptr);
+
+ virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ bool can_create);
+
+ virtual size_t GetIndexOfChildWithName(const ConstString &name);
+
+ size_t GetNumChildren(uint32_t max = UINT32_MAX);
+
+ const Value &GetValue() const;
+
+ Value &GetValue();
+
+ virtual bool ResolveValue(Scalar &scalar);
+
+ // return 'false' whenever you set the error, otherwise
+ // callers may assume true means everything is OK - this will
+ // break breakpoint conditions among potentially a few others
+ virtual bool IsLogicalTrue(Error &error);
+
+ virtual const char *GetLocationAsCString();
+
+ const char *
+ GetSummaryAsCString(lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ bool
+ GetSummaryAsCString(TypeSummaryImpl *summary_ptr, std::string &destination,
+ lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ bool GetSummaryAsCString(std::string &destination,
+ const TypeSummaryOptions &options);
+
+ bool GetSummaryAsCString(TypeSummaryImpl *summary_ptr,
+ std::string &destination,
+ const TypeSummaryOptions &options);
+
+ std::pair<TypeValidatorResult, std::string> GetValidationStatus();
+
+ const char *GetObjectDescription();
+
+ bool HasSpecialPrintableRepresentation(
+ ValueObjectRepresentationStyle val_obj_display,
+ lldb::Format custom_format);
+
+ enum PrintableRepresentationSpecialCases {
+ ePrintableRepresentationSpecialCasesDisable = 0,
+ ePrintableRepresentationSpecialCasesAllow = 1,
+ ePrintableRepresentationSpecialCasesOnly = 3
+ };
+
+ bool
+ DumpPrintableRepresentation(Stream &s,
+ ValueObjectRepresentationStyle val_obj_display =
+ eValueObjectRepresentationStyleSummary,
+ lldb::Format custom_format = lldb::eFormatInvalid,
+ PrintableRepresentationSpecialCases special =
+ ePrintableRepresentationSpecialCasesAllow,
+ bool do_dump_error = true);
+ bool GetValueIsValid() const;
+
+ // If you call this on a newly created ValueObject, it will always return
+ // false.
+ bool GetValueDidChange();
+
+ bool UpdateValueIfNeeded(bool update_format = true);
+
+ bool UpdateFormatsIfNeeded();
+
+ lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
+
+ void SetName(const ConstString &name);
+
+ virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr);
+
+ lldb::addr_t GetPointerValue(AddressType *address_type = nullptr);
+
+ lldb::ValueObjectSP GetSyntheticChild(const ConstString &key) const;
+
+ lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
+
+ lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
+ bool can_create);
+
+ lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char *expression,
+ bool can_create);
+
+ virtual lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
+ bool can_create,
+ ConstString name_const_str = ConstString());
+
+ virtual lldb::ValueObjectSP
+ GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString());
+
+ virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType);
+
+ lldb::DynamicValueType GetDynamicValueType();
+
+ virtual lldb::ValueObjectSP GetStaticValue();
+
+ virtual lldb::ValueObjectSP GetNonSyntheticValue();
+
+ lldb::ValueObjectSP GetSyntheticValue(bool use_synthetic = true);
+
+ virtual bool HasSyntheticValue();
+
+ virtual bool IsSynthetic() { return false; }
+
+ lldb::ValueObjectSP
+ GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue,
+ bool synthValue);
+
+ virtual lldb::ValueObjectSP CreateConstantValue(const ConstString &name);
+
+ virtual lldb::ValueObjectSP Dereference(Error &error);
+
+ virtual lldb::ValueObjectSP AddressOf(Error &error);
+
+ virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; }
+
+ virtual void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
+ AddressType address_type = eAddressTypeLoad) {}
+
+ // Find the address of the C++ vtable pointer
+ virtual lldb::addr_t GetCPPVTableAddress(AddressType &address_type);
+
+ virtual lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
+
+ virtual lldb::ValueObjectSP CastPointerType(const char *name,
+ CompilerType &ast_type);
+
+ virtual lldb::ValueObjectSP CastPointerType(const char *name,
+ lldb::TypeSP &type_sp);
+
+ // The backing bits of this value object were updated, clear any
+ // descriptive string, so we know we have to refetch them
+ virtual void ValueUpdated() {
+ ClearUserVisibleData(eClearUserVisibleDataItemsValue |
+ eClearUserVisibleDataItemsSummary |
+ eClearUserVisibleDataItemsDescription);
+ }
+
+ virtual bool IsDynamic() { return false; }
+
+ virtual bool DoesProvideSyntheticValue() { return false; }
+
+ virtual bool IsSyntheticChildrenGenerated();
+
+ virtual void SetSyntheticChildrenGenerated(bool b);
+
+ virtual SymbolContextScope *GetSymbolContextScope();
+
+ void Dump(Stream &s);
+
+ void Dump(Stream &s, const DumpValueObjectOptions &options);
+
+ static lldb::ValueObjectSP
+ CreateValueObjectFromExpression(const char *name, const char *expression,
+ const ExecutionContext &exe_ctx);
+
+ static lldb::ValueObjectSP
+ CreateValueObjectFromExpression(const char *name, const char *expression,
+ const ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options);
+
+ static lldb::ValueObjectSP
+ CreateValueObjectFromAddress(const char *name, uint64_t address,
+ const ExecutionContext &exe_ctx,
CompilerType type);
-
- void
- LogValueObject (Log *log);
-
- void
- LogValueObject (Log *log,
- const DumpValueObjectOptions& options);
-
-
- lldb::ValueObjectSP
- Persist ();
-
- // returns true if this is a char* or a char[]
- // if it is a char* and check_pointer is true,
- // it also checks that the pointer is valid
- bool
- IsCStringContainer (bool check_pointer = false);
-
- std::pair<size_t,bool>
- ReadPointedString (lldb::DataBufferSP& buffer_sp,
- Error& error,
- uint32_t max_length = 0,
- bool honor_array = true,
- lldb::Format item_format = lldb::eFormatCharArray);
-
- virtual size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1);
-
- virtual uint64_t
- GetData (DataExtractor& data, Error &error);
-
- virtual bool
- SetData (DataExtractor &data, Error &error);
-
- virtual bool
- GetIsConstant () const
- {
- return m_update_point.IsConstant();
- }
-
- bool
- NeedsUpdating ()
- {
- const bool accept_invalid_exe_ctx = (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes);
- return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
- }
-
- void
- SetIsConstant ()
- {
- m_update_point.SetIsConstant();
- }
- lldb::Format
- GetFormat () const;
-
- virtual void
- SetFormat (lldb::Format format)
- {
- if (format != m_format)
- ClearUserVisibleData(eClearUserVisibleDataItemsValue);
- m_format = format;
- }
+ static lldb::ValueObjectSP
+ CreateValueObjectFromData(const char *name, const DataExtractor &data,
+ const ExecutionContext &exe_ctx, CompilerType type);
- virtual lldb::LanguageType
- GetPreferredDisplayLanguage ();
-
- void
- SetPreferredDisplayLanguage (lldb::LanguageType);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat()
- {
- UpdateFormatsIfNeeded();
- return m_type_summary_sp;
- }
-
- void
- SetSummaryFormat(lldb::TypeSummaryImplSP format)
- {
- m_type_summary_sp = format;
- ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
- }
-
- lldb::TypeValidatorImplSP
- GetValidator()
- {
- UpdateFormatsIfNeeded();
- return m_type_validator_sp;
- }
-
- void
- SetValidator(lldb::TypeValidatorImplSP format)
- {
- m_type_validator_sp = format;
- ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
- }
-
- void
- SetValueFormat(lldb::TypeFormatImplSP format)
- {
- m_type_format_sp = format;
- ClearUserVisibleData(eClearUserVisibleDataItemsValue);
- }
-
- lldb::TypeFormatImplSP
- GetValueFormat()
- {
- UpdateFormatsIfNeeded();
- return m_type_format_sp;
- }
-
- void
- SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp)
- {
- if (synth_sp.get() == m_synthetic_children_sp.get())
- return;
- ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
- m_synthetic_children_sp = synth_sp;
- }
-
- lldb::SyntheticChildrenSP
- GetSyntheticChildren()
- {
- UpdateFormatsIfNeeded();
- return m_synthetic_children_sp;
- }
+ void LogValueObject(Log *log);
- // Use GetParent for display purposes, but if you want to tell the parent to update itself
- // then use m_parent. The ValueObjectDynamicValue's parent is not the correct parent for
- // displaying, they are really siblings, so for display it needs to route through to its grandparent.
- virtual ValueObject *
- GetParent()
- {
- return m_parent;
- }
+ void LogValueObject(Log *log, const DumpValueObjectOptions &options);
- virtual const ValueObject *
- GetParent() const
- {
- return m_parent;
- }
+ lldb::ValueObjectSP Persist();
- ValueObject *
- GetNonBaseClassParent();
+ // returns true if this is a char* or a char[]
+ // if it is a char* and check_pointer is true,
+ // it also checks that the pointer is valid
+ bool IsCStringContainer(bool check_pointer = false);
- void
- SetAddressTypeOfChildren(AddressType at)
- {
- m_address_type_of_ptr_or_ref_children = at;
- }
-
- AddressType
- GetAddressTypeOfChildren();
-
- void
- SetHasCompleteType()
- {
- m_did_calculate_complete_objc_class_type = true;
- }
-
- //------------------------------------------------------------------
- /// Find out if a ValueObject might have children.
- ///
- /// This call is much more efficient than CalculateNumChildren() as
- /// it doesn't need to complete the underlying type. This is designed
- /// to be used in a UI environment in order to detect if the
- /// disclosure triangle should be displayed or not.
- ///
- /// This function returns true for class, union, structure,
- /// pointers, references, arrays and more. Again, it does so without
- /// doing any expensive type completion.
- ///
- /// @return
- /// Returns \b true if the ValueObject might have children, or \b
- /// false otherwise.
- //------------------------------------------------------------------
- virtual bool
- MightHaveChildren();
-
- virtual lldb::VariableSP
- GetVariable ()
- {
- return nullptr;
- }
+ std::pair<size_t, bool>
+ ReadPointedString(lldb::DataBufferSP &buffer_sp, Error &error,
+ uint32_t max_length = 0, bool honor_array = true,
+ lldb::Format item_format = lldb::eFormatCharArray);
+
+ virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1);
+
+ virtual uint64_t GetData(DataExtractor &data, Error &error);
+
+ virtual bool SetData(DataExtractor &data, Error &error);
+
+ virtual bool GetIsConstant() const { return m_update_point.IsConstant(); }
+
+ bool NeedsUpdating() {
+ const bool accept_invalid_exe_ctx =
+ (CanUpdateWithInvalidExecutionContext() == eLazyBoolYes);
+ return m_update_point.NeedsUpdating(accept_invalid_exe_ctx);
+ }
+
+ void SetIsConstant() { m_update_point.SetIsConstant(); }
+
+ lldb::Format GetFormat() const;
+
+ virtual void SetFormat(lldb::Format format) {
+ if (format != m_format)
+ ClearUserVisibleData(eClearUserVisibleDataItemsValue);
+ m_format = format;
+ }
+
+ virtual lldb::LanguageType GetPreferredDisplayLanguage();
+
+ void SetPreferredDisplayLanguage(lldb::LanguageType);
+
+ lldb::TypeSummaryImplSP GetSummaryFormat() {
+ UpdateFormatsIfNeeded();
+ return m_type_summary_sp;
+ }
+
+ void SetSummaryFormat(lldb::TypeSummaryImplSP format) {
+ m_type_summary_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
+ }
+
+ lldb::TypeValidatorImplSP GetValidator() {
+ UpdateFormatsIfNeeded();
+ return m_type_validator_sp;
+ }
+
+ void SetValidator(lldb::TypeValidatorImplSP format) {
+ m_type_validator_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsValidator);
+ }
+
+ void SetValueFormat(lldb::TypeFormatImplSP format) {
+ m_type_format_sp = format;
+ ClearUserVisibleData(eClearUserVisibleDataItemsValue);
+ }
+
+ lldb::TypeFormatImplSP GetValueFormat() {
+ UpdateFormatsIfNeeded();
+ return m_type_format_sp;
+ }
+
+ void SetSyntheticChildren(const lldb::SyntheticChildrenSP &synth_sp) {
+ if (synth_sp.get() == m_synthetic_children_sp.get())
+ return;
+ ClearUserVisibleData(eClearUserVisibleDataItemsSyntheticChildren);
+ m_synthetic_children_sp = synth_sp;
+ }
+
+ lldb::SyntheticChildrenSP GetSyntheticChildren() {
+ UpdateFormatsIfNeeded();
+ return m_synthetic_children_sp;
+ }
+
+ // Use GetParent for display purposes, but if you want to tell the parent to
+ // update itself
+ // then use m_parent. The ValueObjectDynamicValue's parent is not the correct
+ // parent for
+ // displaying, they are really siblings, so for display it needs to route
+ // through to its grandparent.
+ virtual ValueObject *GetParent() { return m_parent; }
+
+ virtual const ValueObject *GetParent() const { return m_parent; }
+
+ ValueObject *GetNonBaseClassParent();
+
+ void SetAddressTypeOfChildren(AddressType at) {
+ m_address_type_of_ptr_or_ref_children = at;
+ }
+
+ AddressType GetAddressTypeOfChildren();
+
+ void SetHasCompleteType() { m_did_calculate_complete_objc_class_type = true; }
+
+ //------------------------------------------------------------------
+ /// Find out if a ValueObject might have children.
+ ///
+ /// This call is much more efficient than CalculateNumChildren() as
+ /// it doesn't need to complete the underlying type. This is designed
+ /// to be used in a UI environment in order to detect if the
+ /// disclosure triangle should be displayed or not.
+ ///
+ /// This function returns true for class, union, structure,
+ /// pointers, references, arrays and more. Again, it does so without
+ /// doing any expensive type completion.
+ ///
+ /// @return
+ /// Returns \b true if the ValueObject might have children, or \b
+ /// false otherwise.
+ //------------------------------------------------------------------
+ virtual bool MightHaveChildren();
- virtual bool
- IsRuntimeSupportValue ();
-
- virtual uint64_t
- GetLanguageFlags ();
-
- virtual void
- SetLanguageFlags (uint64_t flags);
+ virtual lldb::VariableSP GetVariable() { return nullptr; }
+
+ virtual bool IsRuntimeSupportValue();
+
+ virtual uint64_t GetLanguageFlags();
+
+ virtual void SetLanguageFlags(uint64_t flags);
protected:
- typedef ClusterManager<ValueObject> ValueObjectManager;
-
- class ChildrenManager
- {
- public:
- ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {}
-
- bool
- HasChildAtIndex(size_t idx)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- return (m_children.find(idx) != m_children.end());
- }
-
- ValueObject *
- GetChildAtIndex(size_t idx)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- const auto iter = m_children.find(idx);
- return ((iter == m_children.end()) ? nullptr : iter->second);
- }
-
- void
- SetChildAtIndex(size_t idx, ValueObject *valobj)
- {
- // we do not need to be mutex-protected to make a pair
- ChildrenPair pair(idx, valobj);
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_children.insert(pair);
- }
-
- void
- SetChildrenCount (size_t count)
- {
- Clear(count);
- }
-
- size_t
- GetChildrenCount ()
- {
- return m_children_count;
- }
-
- void
- Clear(size_t new_count = 0)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_children_count = new_count;
- m_children.clear();
- }
-
- private:
- typedef std::map<size_t, ValueObject*> ChildrenMap;
- typedef ChildrenMap::iterator ChildrenIterator;
- typedef ChildrenMap::value_type ChildrenPair;
- std::recursive_mutex m_mutex;
- ChildrenMap m_children;
- size_t m_children_count;
- };
+ typedef ClusterManager<ValueObject> ValueObjectManager;
- //------------------------------------------------------------------
- // Classes that inherit from ValueObject can see and modify these
- //------------------------------------------------------------------
- ValueObject * m_parent; // The parent value object, or nullptr if this has no parent
- ValueObject * m_root; // The root of the hierarchy for this ValueObject (or nullptr if never calculated)
- EvaluationPoint m_update_point; // Stores both the stop id and the full context at which this value was last
- // updated. When we are asked to update the value object, we check whether
- // the context & stop id are the same before updating.
- ConstString m_name; // The name of this object
- DataExtractor m_data; // A data extractor that can be used to extract the value.
- Value m_value;
- Error m_error; // An error object that can describe any errors that occur when updating values.
- std::string m_value_str; // Cached value string that will get cleared if/when the value is updated.
- std::string m_old_value_str;// Cached old value string from the last time the value was gotten
- std::string m_location_str; // Cached location string that will get cleared if/when the value is updated.
- std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated.
- std::string m_object_desc_str; // Cached result of the "object printer". This differs from the summary
- // in that the summary is consed up by us, the object_desc_string is builtin.
-
- llvm::Optional<std::pair<TypeValidatorResult, std::string>> m_validation_result;
-
- CompilerType m_override_type;// If the type of the value object should be overridden, the type to impose.
-
- ValueObjectManager *m_manager; // This object is managed by the root object (any ValueObject that gets created
- // without a parent.) The manager gets passed through all the generations of
- // dependent objects, and will keep the whole cluster of objects alive as long
- // as a shared pointer to any of them has been handed out. Shared pointers to
- // value objects must always be made with the GetSP method.
-
- ChildrenManager m_children;
- std::map<ConstString, ValueObject *> m_synthetic_children;
-
- ValueObject* m_dynamic_value;
- ValueObject* m_synthetic_value;
- ValueObject* m_deref_valobj;
-
- lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared pointer to this one because it is created
- // as an independent ValueObjectConstResult, which isn't managed by us.
-
- lldb::Format m_format;
- lldb::Format m_last_format;
- uint32_t m_last_format_mgr_revision;
- lldb::TypeSummaryImplSP m_type_summary_sp;
- lldb::TypeFormatImplSP m_type_format_sp;
- lldb::SyntheticChildrenSP m_synthetic_children_sp;
- lldb::TypeValidatorImplSP m_type_validator_sp;
- ProcessModID m_user_id_of_forced_summary;
- AddressType m_address_type_of_ptr_or_ref_children;
-
- llvm::SmallVector<uint8_t, 16> m_value_checksum;
-
- lldb::LanguageType m_preferred_display_language;
-
- uint64_t m_language_flags;
-
- bool m_value_is_valid:1,
- m_value_did_change:1,
- m_children_count_valid:1,
- m_old_value_valid:1,
- m_is_deref_of_parent:1,
- m_is_array_item_for_pointer:1,
- m_is_bitfield_for_scalar:1,
- m_is_child_at_offset:1,
- m_is_getting_summary:1,
- m_did_calculate_complete_objc_class_type:1,
- m_is_synthetic_children_generated:1;
-
- friend class ValueObjectChild;
- friend class ClangExpressionDeclMap; // For GetValue
- friend class ExpressionVariable; // For SetName
- friend class Target; // For SetName
- friend class ValueObjectConstResultImpl;
- friend class ValueObjectSynthetic; // For ClearUserVisibleData
-
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
-
- // Use the no-argument constructor to make a constant variable object (with no ExecutionContextScope.)
-
- ValueObject();
-
- // Use this constructor to create a "root variable object". The ValueObject will be locked to this context
- // through-out its lifespan.
-
- ValueObject (ExecutionContextScope *exe_scope,
- AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
-
- // Use this constructor to create a ValueObject owned by another ValueObject. It will inherit the ExecutionContext
- // of its parent.
-
- ValueObject (ValueObject &parent);
-
- ValueObjectManager *
- GetManager()
- {
- return m_manager;
+ class ChildrenManager {
+ public:
+ ChildrenManager() : m_mutex(), m_children(), m_children_count(0) {}
+
+ bool HasChildAtIndex(size_t idx) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ return (m_children.find(idx) != m_children.end());
}
-
- virtual bool
- UpdateValue () = 0;
-
- virtual LazyBool
- CanUpdateWithInvalidExecutionContext ()
- {
- return eLazyBoolCalculate;
+
+ ValueObject *GetChildAtIndex(size_t idx) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ const auto iter = m_children.find(idx);
+ return ((iter == m_children.end()) ? nullptr : iter->second);
}
-
- virtual void
- CalculateDynamicValue (lldb::DynamicValueType use_dynamic);
-
- virtual lldb::DynamicValueType
- GetDynamicValueTypeImpl ()
- {
- return lldb::eNoDynamicValues;
+
+ void SetChildAtIndex(size_t idx, ValueObject *valobj) {
+ // we do not need to be mutex-protected to make a pair
+ ChildrenPair pair(idx, valobj);
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_children.insert(pair);
}
-
- virtual bool
- HasDynamicValueTypeInfo ()
- {
- return false;
+
+ void SetChildrenCount(size_t count) { Clear(count); }
+
+ size_t GetChildrenCount() { return m_children_count; }
+
+ void Clear(size_t new_count = 0) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_children_count = new_count;
+ m_children.clear();
}
-
- virtual void
- CalculateSyntheticValue (bool use_synthetic = true);
-
- // Should only be called by ValueObject::GetChildAtIndex()
- // Returns a ValueObject managed by this ValueObject's manager.
- virtual ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
-
- // Should only be called by ValueObject::GetNumChildren()
- virtual size_t
- CalculateNumChildren(uint32_t max=UINT32_MAX) = 0;
-
- void
- SetNumChildren (size_t num_children);
-
- void
- SetValueDidChange (bool value_changed);
-
- void
- SetValueIsValid (bool valid);
-
- void
- ClearUserVisibleData(uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
-
- void
- AddSyntheticChild (const ConstString &key,
- ValueObject *valobj);
-
- DataExtractor &
- GetDataExtractor ();
-
- void
- ClearDynamicTypeInformation ();
-
- //------------------------------------------------------------------
- // Subclasses must implement the functions below.
- //------------------------------------------------------------------
-
- virtual CompilerType
- GetCompilerTypeImpl () = 0;
-
- const char *
- GetLocationAsCStringImpl (const Value& value,
- const DataExtractor& data);
-
- bool
- IsChecksumEmpty ();
-
- void
- SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType);
-
+
+ private:
+ typedef std::map<size_t, ValueObject *> ChildrenMap;
+ typedef ChildrenMap::iterator ChildrenIterator;
+ typedef ChildrenMap::value_type ChildrenPair;
+ std::recursive_mutex m_mutex;
+ ChildrenMap m_children;
+ size_t m_children_count;
+ };
+
+ //------------------------------------------------------------------
+ // Classes that inherit from ValueObject can see and modify these
+ //------------------------------------------------------------------
+ ValueObject
+ *m_parent; // The parent value object, or nullptr if this has no parent
+ ValueObject *m_root; // The root of the hierarchy for this ValueObject (or
+ // nullptr if never calculated)
+ EvaluationPoint m_update_point; // Stores both the stop id and the full
+ // context at which this value was last
+ // updated. When we are asked to update the value object, we check whether
+ // the context & stop id are the same before updating.
+ ConstString m_name; // The name of this object
+ DataExtractor
+ m_data; // A data extractor that can be used to extract the value.
+ Value m_value;
+ Error m_error; // An error object that can describe any errors that occur when
+ // updating values.
+ std::string m_value_str; // Cached value string that will get cleared if/when
+ // the value is updated.
+ std::string m_old_value_str; // Cached old value string from the last time the
+ // value was gotten
+ std::string m_location_str; // Cached location string that will get cleared
+ // if/when the value is updated.
+ std::string m_summary_str; // Cached summary string that will get cleared
+ // if/when the value is updated.
+ std::string m_object_desc_str; // Cached result of the "object printer". This
+ // differs from the summary
+ // in that the summary is consed up by us, the object_desc_string is builtin.
+
+ llvm::Optional<std::pair<TypeValidatorResult, std::string>>
+ m_validation_result;
+
+ CompilerType m_override_type; // If the type of the value object should be
+ // overridden, the type to impose.
+
+ ValueObjectManager *m_manager; // This object is managed by the root object
+ // (any ValueObject that gets created
+ // without a parent.) The manager gets passed through all the generations of
+ // dependent objects, and will keep the whole cluster of objects alive as long
+ // as a shared pointer to any of them has been handed out. Shared pointers to
+ // value objects must always be made with the GetSP method.
+
+ ChildrenManager m_children;
+ std::map<ConstString, ValueObject *> m_synthetic_children;
+
+ ValueObject *m_dynamic_value;
+ ValueObject *m_synthetic_value;
+ ValueObject *m_deref_valobj;
+
+ lldb::ValueObjectSP m_addr_of_valobj_sp; // We have to hold onto a shared
+ // pointer to this one because it is
+ // created
+ // as an independent ValueObjectConstResult, which isn't managed by us.
+
+ lldb::Format m_format;
+ lldb::Format m_last_format;
+ uint32_t m_last_format_mgr_revision;
+ lldb::TypeSummaryImplSP m_type_summary_sp;
+ lldb::TypeFormatImplSP m_type_format_sp;
+ lldb::SyntheticChildrenSP m_synthetic_children_sp;
+ lldb::TypeValidatorImplSP m_type_validator_sp;
+ ProcessModID m_user_id_of_forced_summary;
+ AddressType m_address_type_of_ptr_or_ref_children;
+
+ llvm::SmallVector<uint8_t, 16> m_value_checksum;
+
+ lldb::LanguageType m_preferred_display_language;
+
+ uint64_t m_language_flags;
+
+ bool m_value_is_valid : 1, m_value_did_change : 1, m_children_count_valid : 1,
+ m_old_value_valid : 1, m_is_deref_of_parent : 1,
+ m_is_array_item_for_pointer : 1, m_is_bitfield_for_scalar : 1,
+ m_is_child_at_offset : 1, m_is_getting_summary : 1,
+ m_did_calculate_complete_objc_class_type : 1,
+ m_is_synthetic_children_generated : 1;
+
+ friend class ValueObjectChild;
+ friend class ClangExpressionDeclMap; // For GetValue
+ friend class ExpressionVariable; // For SetName
+ friend class Target; // For SetName
+ friend class ValueObjectConstResultImpl;
+ friend class ValueObjectSynthetic; // For ClearUserVisibleData
+
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+
+ // Use the no-argument constructor to make a constant variable object (with no
+ // ExecutionContextScope.)
+
+ ValueObject();
+
+ // Use this constructor to create a "root variable object". The ValueObject
+ // will be locked to this context
+ // through-out its lifespan.
+
+ ValueObject(ExecutionContextScope *exe_scope,
+ AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
+
+ // Use this constructor to create a ValueObject owned by another ValueObject.
+ // It will inherit the ExecutionContext
+ // of its parent.
+
+ ValueObject(ValueObject &parent);
+
+ ValueObjectManager *GetManager() { return m_manager; }
+
+ virtual bool UpdateValue() = 0;
+
+ virtual LazyBool CanUpdateWithInvalidExecutionContext() {
+ return eLazyBoolCalculate;
+ }
+
+ virtual void CalculateDynamicValue(lldb::DynamicValueType use_dynamic);
+
+ virtual lldb::DynamicValueType GetDynamicValueTypeImpl() {
+ return lldb::eNoDynamicValues;
+ }
+
+ virtual bool HasDynamicValueTypeInfo() { return false; }
+
+ virtual void CalculateSyntheticValue(bool use_synthetic = true);
+
+ // Should only be called by ValueObject::GetChildAtIndex()
+ // Returns a ValueObject managed by this ValueObject's manager.
+ virtual ValueObject *CreateChildAtIndex(size_t idx,
+ bool synthetic_array_member,
+ int32_t synthetic_index);
+
+ // Should only be called by ValueObject::GetNumChildren()
+ virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0;
+
+ void SetNumChildren(size_t num_children);
+
+ void SetValueDidChange(bool value_changed);
+
+ void SetValueIsValid(bool valid);
+
+ void ClearUserVisibleData(
+ uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
+
+ void AddSyntheticChild(const ConstString &key, ValueObject *valobj);
+
+ DataExtractor &GetDataExtractor();
+
+ void ClearDynamicTypeInformation();
+
+ //------------------------------------------------------------------
+ // Subclasses must implement the functions below.
+ //------------------------------------------------------------------
+
+ virtual CompilerType GetCompilerTypeImpl() = 0;
+
+ const char *GetLocationAsCStringImpl(const Value &value,
+ const DataExtractor &data);
+
+ bool IsChecksumEmpty();
+
+ void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);
+
private:
- virtual CompilerType
- MaybeCalculateCompleteType ();
-
- lldb::ValueObjectSP
- GetValueForExpressionPath_Impl(const char* expression_cstr,
- const char** first_unparsed,
- ExpressionPathScanEndReason* reason_to_stop,
- ExpressionPathEndResultType* final_value_type,
- const GetValueForExpressionPathOptions& options,
- ExpressionPathAftermath* final_task_on_target);
-
- // this method will ONLY expand [] expressions into a VOList and return
- // the number of elements it added to the VOList
- // it will NOT loop through expanding the follow-up of the expression_cstr
- // for all objects in the list
- int
- ExpandArraySliceExpression(const char* expression_cstr,
- const char** first_unparsed,
- lldb::ValueObjectSP root,
- lldb::ValueObjectListSP& list,
- ExpressionPathScanEndReason* reason_to_stop,
- ExpressionPathEndResultType* final_value_type,
- const GetValueForExpressionPathOptions& options,
- ExpressionPathAftermath* final_task_on_target);
+ virtual CompilerType MaybeCalculateCompleteType();
+
+ lldb::ValueObjectSP GetValueForExpressionPath_Impl(
+ const char *expression_cstr, const char **first_unparsed,
+ ExpressionPathScanEndReason *reason_to_stop,
+ ExpressionPathEndResultType *final_value_type,
+ const GetValueForExpressionPathOptions &options,
+ ExpressionPathAftermath *final_task_on_target);
+
+ // this method will ONLY expand [] expressions into a VOList and return
+ // the number of elements it added to the VOList
+ // it will NOT loop through expanding the follow-up of the expression_cstr
+ // for all objects in the list
+ int ExpandArraySliceExpression(
+ const char *expression_cstr, const char **first_unparsed,
+ lldb::ValueObjectSP root, lldb::ValueObjectListSP &list,
+ ExpressionPathScanEndReason *reason_to_stop,
+ ExpressionPathEndResultType *final_value_type,
+ const GetValueForExpressionPathOptions &options,
+ ExpressionPathAftermath *final_task_on_target);
- DISALLOW_COPY_AND_ASSIGN (ValueObject);
+ DISALLOW_COPY_AND_ASSIGN(ValueObject);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectCast.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectCast.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectCast.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectCast.h Tue Sep 6 15:57:50 2016
@@ -21,55 +21,42 @@ namespace lldb_private {
//---------------------------------------------------------------------------------
// A ValueObject that represents a given value represented as a different type.
//---------------------------------------------------------------------------------
-class ValueObjectCast : public ValueObject
-{
+class ValueObjectCast : public ValueObject {
public:
- ~ValueObjectCast() override;
+ ~ValueObjectCast() override;
+
+ static lldb::ValueObjectSP Create(ValueObject &parent,
+ const ConstString &name,
+ const CompilerType &cast_type);
+
+ uint64_t GetByteSize() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ ValueObject *GetParent() override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ const ValueObject *GetParent() const override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
- static lldb::ValueObjectSP
- Create (ValueObject &parent,
- const ConstString &name,
- const CompilerType &cast_type);
-
- uint64_t
- GetByteSize() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- bool
- IsInScope() override;
-
- ValueObject *
- GetParent() override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- const ValueObject *
- GetParent() const override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
protected:
- ValueObjectCast(ValueObject &parent,
- const ConstString &name,
- const CompilerType &cast_type);
-
- bool
- UpdateValue () override;
-
- CompilerType
- GetCompilerTypeImpl () override;
-
- CompilerType m_cast_type;
-
+ ValueObjectCast(ValueObject &parent, const ConstString &name,
+ const CompilerType &cast_type);
+
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ CompilerType m_cast_type;
+
private:
- DISALLOW_COPY_AND_ASSIGN (ValueObjectCast);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectCast);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectChild.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectChild.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectChild.h Tue Sep 6 15:57:50 2016
@@ -23,110 +23,69 @@ namespace lldb_private {
//----------------------------------------------------------------------
// A child of another ValueObject.
//----------------------------------------------------------------------
-class ValueObjectChild : public ValueObject
-{
+class ValueObjectChild : public ValueObject {
public:
- ~ValueObjectChild() override;
+ ~ValueObjectChild() override;
- uint64_t
- GetByteSize() override
- {
- return m_byte_size;
- }
-
- lldb::offset_t
- GetByteOffset() override
- {
- return m_byte_offset;
- }
-
- uint32_t
- GetBitfieldBitSize() override
- {
- return m_bitfield_bit_size;
- }
-
- uint32_t
- GetBitfieldBitOffset() override
- {
- return m_bitfield_bit_offset;
- }
-
- lldb::ValueType
- GetValueType() const override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- bool
- IsInScope() override;
-
- bool
- IsBaseClass() override
- {
- return m_is_base_class;
- }
-
- bool
- IsDereferenceOfParent() override
- {
- return m_is_deref_of_parent;
- }
+ uint64_t GetByteSize() override { return m_byte_size; }
+
+ lldb::offset_t GetByteOffset() override { return m_byte_offset; }
+
+ uint32_t GetBitfieldBitSize() override { return m_bitfield_bit_size; }
+
+ uint32_t GetBitfieldBitOffset() override { return m_bitfield_bit_offset; }
+
+ lldb::ValueType GetValueType() const override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ bool IsInScope() override;
+
+ bool IsBaseClass() override { return m_is_base_class; }
+
+ bool IsDereferenceOfParent() override { return m_is_deref_of_parent; }
protected:
- bool
- UpdateValue() override;
-
- LazyBool
- CanUpdateWithInvalidExecutionContext() override;
-
- CompilerType
- GetCompilerTypeImpl() override
- {
- return m_compiler_type;
- }
-
- CompilerType m_compiler_type;
- ConstString m_type_name;
- uint64_t m_byte_size;
- int32_t m_byte_offset;
- uint8_t m_bitfield_bit_size;
- uint8_t m_bitfield_bit_offset;
- bool m_is_base_class;
- bool m_is_deref_of_parent;
- llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx;
-
-//
-// void
-// ReadValueFromMemory (ValueObject* parent, lldb::addr_t address);
+ bool UpdateValue() override;
+
+ LazyBool CanUpdateWithInvalidExecutionContext() override;
+
+ CompilerType GetCompilerTypeImpl() override { return m_compiler_type; }
+
+ CompilerType m_compiler_type;
+ ConstString m_type_name;
+ uint64_t m_byte_size;
+ int32_t m_byte_offset;
+ uint8_t m_bitfield_bit_size;
+ uint8_t m_bitfield_bit_offset;
+ bool m_is_base_class;
+ bool m_is_deref_of_parent;
+ llvm::Optional<LazyBool> m_can_update_with_invalid_exe_ctx;
+
+ //
+ // void
+ // ReadValueFromMemory (ValueObject* parent, lldb::addr_t address);
protected:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- friend class ValueObjectConstResultImpl;
-
- ValueObjectChild (ValueObject &parent,
- const CompilerType &compiler_type,
- const ConstString &name,
- uint64_t byte_size,
- int32_t byte_offset,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool is_base_class,
- bool is_deref_of_parent,
- AddressType child_ptr_or_ref_addr_type,
- uint64_t language_flags);
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
+
+ ValueObjectChild(ValueObject &parent, const CompilerType &compiler_type,
+ const ConstString &name, uint64_t byte_size,
+ int32_t byte_offset, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool is_base_class,
+ bool is_deref_of_parent,
+ AddressType child_ptr_or_ref_addr_type,
+ uint64_t language_flags);
- DISALLOW_COPY_AND_ASSIGN (ValueObjectChild);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectChild);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Tue Sep 6 15:57:50 2016
@@ -23,169 +23,123 @@ namespace lldb_private {
//----------------------------------------------------------------------
// A frozen ValueObject copied into host memory
//----------------------------------------------------------------------
-class ValueObjectConstResult : public ValueObject
-{
+class ValueObjectConstResult : public ValueObject {
public:
- ~ValueObjectConstResult() override;
+ ~ValueObjectConstResult() override;
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size,
- lldb::addr_t address = LLDB_INVALID_ADDRESS);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const DataExtractor &data,
- lldb::addr_t address = LLDB_INVALID_ADDRESS);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const lldb::DataBufferSP &result_data_sp,
- lldb::ByteOrder byte_order,
- uint32_t addr_size,
- lldb::addr_t address = LLDB_INVALID_ADDRESS);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- lldb::addr_t address,
- AddressType address_type,
- uint32_t addr_byte_size);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- Value &value,
- const ConstString &name,
- Module* module = nullptr);
-
- // When an expression fails to evaluate, we return an error
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const Error& error);
-
- uint64_t
- GetByteSize() override;
-
- lldb::ValueType
- GetValueType() const override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- bool
- IsInScope() override;
-
- void
- SetByteSize (size_t size);
-
- lldb::ValueObjectSP
- Dereference(Error &error) override;
-
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString()) override;
-
- lldb::ValueObjectSP
- AddressOf(Error &error) override;
-
- lldb::addr_t
- GetAddressOf(bool scalar_is_load_address = true,
- AddressType *address_type = nullptr) override;
-
- size_t
- GetPointeeData(DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1) override;
-
- lldb::addr_t
- GetLiveAddress() override
- {
- return m_impl.GetLiveAddress();
- }
-
- void
- SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad) override
- {
- m_impl.SetLiveAddress(addr, address_type);
- }
-
- lldb::ValueObjectSP
- GetDynamicValue(lldb::DynamicValueType valueType) override;
-
- lldb::LanguageType
- GetPreferredDisplayLanguage() override;
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order,
+ uint32_t addr_byte_size, lldb::addr_t address = LLDB_INVALID_ADDRESS);
- lldb::ValueObjectSP
- Cast(const CompilerType &compiler_type) override;
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
+ const ConstString &name, const DataExtractor &data,
+ lldb::addr_t address = LLDB_INVALID_ADDRESS);
+
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
+ const ConstString &name, const lldb::DataBufferSP &result_data_sp,
+ lldb::ByteOrder byte_order, uint32_t addr_size,
+ lldb::addr_t address = LLDB_INVALID_ADDRESS);
+
+ static lldb::ValueObjectSP
+ Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
+ const ConstString &name, lldb::addr_t address,
+ AddressType address_type, uint32_t addr_byte_size);
+
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ Value &value, const ConstString &name,
+ Module *module = nullptr);
+
+ // When an expression fails to evaluate, we return an error
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ const Error &error);
+
+ uint64_t GetByteSize() override;
+
+ lldb::ValueType GetValueType() const override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ bool IsInScope() override;
+
+ void SetByteSize(size_t size);
+
+ lldb::ValueObjectSP Dereference(Error &error) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString()) override;
+
+ lldb::ValueObjectSP AddressOf(Error &error) override;
+
+ lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr) override;
+
+ size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
+
+ lldb::addr_t GetLiveAddress() override { return m_impl.GetLiveAddress(); }
+
+ void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
+ AddressType address_type = eAddressTypeLoad) override {
+ m_impl.SetLiveAddress(addr, address_type);
+ }
+
+ lldb::ValueObjectSP
+ GetDynamicValue(lldb::DynamicValueType valueType) override;
+
+ lldb::LanguageType GetPreferredDisplayLanguage() override;
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- ConstString m_type_name;
- uint64_t m_byte_size;
-
- ValueObjectConstResultImpl m_impl;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ ConstString m_type_name;
+ uint64_t m_byte_size;
+
+ ValueObjectConstResultImpl m_impl;
private:
- friend class ValueObjectConstResultImpl;
+ friend class ValueObjectConstResultImpl;
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ lldb::ByteOrder byte_order, uint32_t addr_byte_size,
+ lldb::addr_t address);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ const CompilerType &compiler_type,
+ const ConstString &name, const DataExtractor &data,
+ lldb::addr_t address);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ const CompilerType &compiler_type,
+ const ConstString &name,
+ const lldb::DataBufferSP &result_data_sp,
+ lldb::ByteOrder byte_order, uint32_t addr_size,
+ lldb::addr_t address);
+
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ const CompilerType &compiler_type,
+ const ConstString &name, lldb::addr_t address,
+ AddressType address_type, uint32_t addr_byte_size);
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- lldb::ByteOrder byte_order,
- uint32_t addr_byte_size,
- lldb::addr_t address);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const DataExtractor &data,
- lldb::addr_t address);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- const lldb::DataBufferSP &result_data_sp,
- lldb::ByteOrder byte_order,
- uint32_t addr_size,
- lldb::addr_t address);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- const ConstString &name,
- lldb::addr_t address,
- AddressType address_type,
- uint32_t addr_byte_size);
-
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const Value &value,
- const ConstString &name,
- Module* module = nullptr);
+ ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value,
+ const ConstString &name, Module *module = nullptr);
- ValueObjectConstResult (ExecutionContextScope *exe_scope,
- const Error& error);
+ ValueObjectConstResult(ExecutionContextScope *exe_scope, const Error &error);
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResult);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResultCast.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResultCast.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResultCast.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResultCast.h Tue Sep 6 15:57:50 2016
@@ -19,57 +19,43 @@
namespace lldb_private {
-class ValueObjectConstResultCast : public ValueObjectCast
-{
+class ValueObjectConstResultCast : public ValueObjectCast {
public:
- ValueObjectConstResultCast (
- ValueObject &parent,
- const ConstString &name,
- const CompilerType &cast_type,
- lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
-
- ~ValueObjectConstResultCast() override;
-
- lldb::ValueObjectSP
- Dereference(Error &error) override;
-
- ValueObject *
- CreateChildAtIndex(size_t idx,
- bool synthetic_array_member,
- int32_t synthetic_index) override;
-
- virtual CompilerType
- GetCompilerType ()
- {
- return ValueObjectCast::GetCompilerType();
- }
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString()) override;
-
- lldb::ValueObjectSP
- AddressOf (Error &error) override;
-
- size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1) override;
+ ValueObjectConstResultCast(ValueObject &parent, const ConstString &name,
+ const CompilerType &cast_type,
+ lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
- lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type) override;
+ ~ValueObjectConstResultCast() override;
+
+ lldb::ValueObjectSP Dereference(Error &error) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ virtual CompilerType GetCompilerType() {
+ return ValueObjectCast::GetCompilerType();
+ }
+
+ lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString()) override;
+
+ lldb::ValueObjectSP AddressOf(Error &error) override;
+
+ size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
protected:
- ValueObjectConstResultImpl m_impl;
+ ValueObjectConstResultImpl m_impl;
private:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- friend class ValueObjectConstResultImpl;
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultCast);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultCast);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResultChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResultChild.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResultChild.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResultChild.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ValueObjectConstResultChild.h -------------------------------*- C++ -*-===//
+//===-- ValueObjectConstResultChild.h -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,62 +23,48 @@ namespace lldb_private {
//----------------------------------------------------------------------
// A child of a ValueObjectConstResult.
//----------------------------------------------------------------------
-class ValueObjectConstResultChild : public ValueObjectChild
-{
+class ValueObjectConstResultChild : public ValueObjectChild {
public:
-
- ValueObjectConstResultChild (ValueObject &parent,
- const CompilerType &compiler_type,
- const ConstString &name,
- uint32_t byte_size,
- int32_t byte_offset,
- uint32_t bitfield_bit_size,
- uint32_t bitfield_bit_offset,
- bool is_base_class,
- bool is_deref_of_parent,
- lldb::addr_t live_address,
- uint64_t language_flags);
-
- ~ValueObjectConstResultChild() override;
-
- lldb::ValueObjectSP
- Dereference(Error &error) override;
-
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
-
- virtual CompilerType
- GetCompilerType ()
- {
- return ValueObjectChild::GetCompilerType();
- }
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset(uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString()) override;
-
- lldb::ValueObjectSP
- AddressOf (Error &error) override;
-
- size_t
- GetPointeeData (DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1) override;
-
- lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type) override;
-
+ ValueObjectConstResultChild(ValueObject &parent,
+ const CompilerType &compiler_type,
+ const ConstString &name, uint32_t byte_size,
+ int32_t byte_offset, uint32_t bitfield_bit_size,
+ uint32_t bitfield_bit_offset, bool is_base_class,
+ bool is_deref_of_parent,
+ lldb::addr_t live_address,
+ uint64_t language_flags);
+
+ ~ValueObjectConstResultChild() override;
+
+ lldb::ValueObjectSP Dereference(Error &error) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ virtual CompilerType GetCompilerType() {
+ return ValueObjectChild::GetCompilerType();
+ }
+
+ lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ uint32_t offset, const CompilerType &type, bool can_create,
+ ConstString name_const_str = ConstString()) override;
+
+ lldb::ValueObjectSP AddressOf(Error &error) override;
+
+ size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1) override;
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type) override;
+
protected:
- ValueObjectConstResultImpl m_impl;
-
+ ValueObjectConstResultImpl m_impl;
+
private:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- friend class ValueObjectConstResultImpl;
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ friend class ValueObjectConstResultImpl;
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultChild);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultChild);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h Tue Sep 6 15:57:50 2016
@@ -23,64 +23,49 @@ namespace lldb_private {
// ValueObjectConstResult ( & Child ) that may need to jump from the host
// memory space into the target's memory space
//----------------------------------------------------------------------
-class ValueObjectConstResultImpl
-{
+class ValueObjectConstResultImpl {
public:
- ValueObjectConstResultImpl (ValueObject* valobj,
- lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
+ ValueObjectConstResultImpl(ValueObject *valobj,
+ lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
- virtual
- ~ValueObjectConstResultImpl() = default;
+ virtual ~ValueObjectConstResultImpl() = default;
+
+ lldb::ValueObjectSP Dereference(Error &error);
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index);
+
+ lldb::ValueObjectSP
+ GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
+ bool can_create,
+ ConstString name_const_str = ConstString());
+
+ lldb::ValueObjectSP AddressOf(Error &error);
+
+ lldb::addr_t GetLiveAddress() { return m_live_address; }
+
+ lldb::ValueObjectSP Cast(const CompilerType &compiler_type);
+
+ void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
+ AddressType address_type = eAddressTypeLoad) {
+ m_live_address = addr;
+ m_live_address_type = address_type;
+ }
+
+ virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
+ AddressType *address_type = nullptr);
+
+ virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
+ uint32_t item_count = 1);
- lldb::ValueObjectSP
- Dereference (Error &error);
-
- ValueObject *
- CreateChildAtIndex (size_t idx, bool synthetic_array_member, int32_t synthetic_index);
-
- lldb::ValueObjectSP
- GetSyntheticChildAtOffset (uint32_t offset,
- const CompilerType& type,
- bool can_create,
- ConstString name_const_str = ConstString());
-
- lldb::ValueObjectSP
- AddressOf (Error &error);
-
- lldb::addr_t
- GetLiveAddress()
- {
- return m_live_address;
- }
-
- lldb::ValueObjectSP
- Cast (const CompilerType &compiler_type);
-
- void
- SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS,
- AddressType address_type = eAddressTypeLoad)
- {
- m_live_address = addr;
- m_live_address_type = address_type;
- }
-
- virtual lldb::addr_t
- GetAddressOf(bool scalar_is_load_address = true,
- AddressType *address_type = nullptr);
-
- virtual size_t
- GetPointeeData(DataExtractor& data,
- uint32_t item_idx = 0,
- uint32_t item_count = 1);
-
private:
- ValueObject *m_impl_backend;
- lldb::addr_t m_live_address;
- AddressType m_live_address_type;
- lldb::ValueObjectSP m_load_addr_backend;
- lldb::ValueObjectSP m_address_of_backend;
-
- DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResultImpl);
+ ValueObject *m_impl_backend;
+ lldb::addr_t m_live_address;
+ AddressType m_live_address_type;
+ lldb::ValueObjectSP m_load_addr_backend;
+ lldb::ValueObjectSP m_address_of_backend;
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultImpl);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectDynamicValue.h Tue Sep 6 15:57:50 2016
@@ -20,156 +20,107 @@
namespace lldb_private {
//----------------------------------------------------------------------
-// A ValueObject that represents memory at a given address, viewed as some
+// A ValueObject that represents memory at a given address, viewed as some
// set lldb type.
//----------------------------------------------------------------------
-class ValueObjectDynamicValue : public ValueObject
-{
+class ValueObjectDynamicValue : public ValueObject {
public:
- ~ValueObjectDynamicValue() override;
+ ~ValueObjectDynamicValue() override;
- uint64_t
- GetByteSize() override;
+ uint64_t GetByteSize() override;
- ConstString
- GetTypeName() override;
+ ConstString GetTypeName() override;
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- bool
- IsInScope() override;
-
- bool
- IsDynamic() override
- {
- return true;
- }
-
- bool
- IsBaseClass () override
- {
- if (m_parent)
- return m_parent->IsBaseClass();
- return false;
- }
-
- bool
- GetIsConstant() const override
- {
- return false;
- }
-
- ValueObject *
- GetParent() override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- const ValueObject *
- GetParent() const override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- lldb::ValueObjectSP
- GetStaticValue() override
- {
- return m_parent->GetSP();
- }
-
- void
- SetOwningSP (lldb::ValueObjectSP &owning_sp)
- {
- if (m_owning_valobj_sp == owning_sp)
- return;
-
- assert (m_owning_valobj_sp.get() == nullptr);
- m_owning_valobj_sp = owning_sp;
- }
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- bool
- SetData(DataExtractor &data, Error &error) override;
-
- TypeImpl
- GetTypeImpl() override;
-
- lldb::VariableSP
- GetVariable () override
- {
- return m_parent ? m_parent->GetVariable() : nullptr;
- }
-
- lldb::LanguageType
- GetPreferredDisplayLanguage() override;
-
- void
- SetPreferredDisplayLanguage (lldb::LanguageType);
-
- bool
- IsSyntheticChildrenGenerated () override;
-
- void
- SetSyntheticChildrenGenerated (bool b) override;
-
- bool
- GetDeclaration(Declaration &decl) override;
-
- uint64_t
- GetLanguageFlags () override;
-
- void
- SetLanguageFlags (uint64_t flags) override;
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ bool IsDynamic() override { return true; }
+
+ bool IsBaseClass() override {
+ if (m_parent)
+ return m_parent->IsBaseClass();
+ return false;
+ }
+
+ bool GetIsConstant() const override { return false; }
+
+ ValueObject *GetParent() override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ const ValueObject *GetParent() const override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ lldb::ValueObjectSP GetStaticValue() override { return m_parent->GetSP(); }
+
+ void SetOwningSP(lldb::ValueObjectSP &owning_sp) {
+ if (m_owning_valobj_sp == owning_sp)
+ return;
+
+ assert(m_owning_valobj_sp.get() == nullptr);
+ m_owning_valobj_sp = owning_sp;
+ }
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ bool SetData(DataExtractor &data, Error &error) override;
+
+ TypeImpl GetTypeImpl() override;
+
+ lldb::VariableSP GetVariable() override {
+ return m_parent ? m_parent->GetVariable() : nullptr;
+ }
+
+ lldb::LanguageType GetPreferredDisplayLanguage() override;
+
+ void SetPreferredDisplayLanguage(lldb::LanguageType);
+
+ bool IsSyntheticChildrenGenerated() override;
+
+ void SetSyntheticChildrenGenerated(bool b) override;
+
+ bool GetDeclaration(Declaration &decl) override;
+
+ uint64_t GetLanguageFlags() override;
+
+ void SetLanguageFlags(uint64_t flags) override;
protected:
- bool
- UpdateValue() override;
-
- LazyBool
- CanUpdateWithInvalidExecutionContext() override
- {
- return eLazyBoolYes;
- }
-
- lldb::DynamicValueType
- GetDynamicValueTypeImpl() override
- {
- return m_use_dynamic;
- }
-
- bool
- HasDynamicValueTypeInfo() override
- {
- return true;
- }
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- Address m_address; ///< The variable that this value object is based upon
- TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
- lldb::ValueObjectSP m_owning_valobj_sp;
- lldb::DynamicValueType m_use_dynamic;
- TypeImpl m_type_impl;
+ bool UpdateValue() override;
+
+ LazyBool CanUpdateWithInvalidExecutionContext() override {
+ return eLazyBoolYes;
+ }
+
+ lldb::DynamicValueType GetDynamicValueTypeImpl() override {
+ return m_use_dynamic;
+ }
+
+ bool HasDynamicValueTypeInfo() override { return true; }
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ Address m_address; ///< The variable that this value object is based upon
+ TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name
+ lldb::ValueObjectSP m_owning_valobj_sp;
+ lldb::DynamicValueType m_use_dynamic;
+ TypeImpl m_type_impl;
private:
- friend class ValueObject;
- friend class ValueObjectConstResult;
- ValueObjectDynamicValue (ValueObject &parent, lldb::DynamicValueType use_dynamic);
+ friend class ValueObject;
+ friend class ValueObjectConstResult;
+ ValueObjectDynamicValue(ValueObject &parent,
+ lldb::DynamicValueType use_dynamic);
- DISALLOW_COPY_AND_ASSIGN (ValueObjectDynamicValue);
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectDynamicValue);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectList.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectList.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectList.h Tue Sep 6 15:57:50 2016
@@ -16,80 +16,60 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/UserID.h"
#include "lldb/Target/ExecutionContextScope.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
//----------------------------------------------------------------------
// A collection of ValueObject values that
//----------------------------------------------------------------------
-class ValueObjectList
-{
+class ValueObjectList {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ValueObjectList ();
-
- ValueObjectList (const ValueObjectList &rhs);
-
- ~ValueObjectList();
-
- const ValueObjectList &
- operator = (const ValueObjectList &rhs);
-
- void
- Append (const lldb::ValueObjectSP &val_obj_sp);
-
- void
- Append (const ValueObjectList &valobj_list);
-
- lldb::ValueObjectSP
- FindValueObjectByPointer (ValueObject *valobj);
-
- size_t
- GetSize () const;
-
- void
- Resize (size_t size);
-
- lldb::ValueObjectSP
- GetValueObjectAtIndex (size_t idx);
-
- lldb::ValueObjectSP
- RemoveValueObjectAtIndex (size_t idx);
-
- void
- SetValueObjectAtIndex (size_t idx,
- const lldb::ValueObjectSP &valobj_sp);
-
- lldb::ValueObjectSP
- FindValueObjectByValueName (const char *name);
-
- lldb::ValueObjectSP
- FindValueObjectByUID (lldb::user_id_t uid);
-
- void
- Swap (ValueObjectList &value_object_list);
-
- void
- Clear ()
- {
- m_value_objects.clear();
- }
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ValueObjectList();
-protected:
- typedef std::vector<lldb::ValueObjectSP> collection;
- //------------------------------------------------------------------
- // Classes that inherit from ValueObjectList can see and modify these
- //------------------------------------------------------------------
- collection m_value_objects;
+ ValueObjectList(const ValueObjectList &rhs);
-};
+ ~ValueObjectList();
+
+ const ValueObjectList &operator=(const ValueObjectList &rhs);
+
+ void Append(const lldb::ValueObjectSP &val_obj_sp);
+
+ void Append(const ValueObjectList &valobj_list);
+
+ lldb::ValueObjectSP FindValueObjectByPointer(ValueObject *valobj);
+
+ size_t GetSize() const;
+
+ void Resize(size_t size);
+ lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx);
+
+ lldb::ValueObjectSP RemoveValueObjectAtIndex(size_t idx);
+
+ void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp);
+
+ lldb::ValueObjectSP FindValueObjectByValueName(const char *name);
+
+ lldb::ValueObjectSP FindValueObjectByUID(lldb::user_id_t uid);
+
+ void Swap(ValueObjectList &value_object_list);
+
+ void Clear() { m_value_objects.clear(); }
+
+protected:
+ typedef std::vector<lldb::ValueObjectSP> collection;
+ //------------------------------------------------------------------
+ // Classes that inherit from ValueObjectList can see and modify these
+ //------------------------------------------------------------------
+ collection m_value_objects;
+};
} // namespace lldb_private
-#endif // liblldb_ValueObjectList_h_
+#endif // liblldb_ValueObjectList_h_
Modified: lldb/trunk/include/lldb/Core/ValueObjectMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectMemory.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectMemory.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectMemory.h Tue Sep 6 15:57:50 2016
@@ -20,72 +20,54 @@
namespace lldb_private {
//----------------------------------------------------------------------
-// A ValueObject that represents memory at a given address, viewed as some
+// A ValueObject that represents memory at a given address, viewed as some
// set lldb type.
//----------------------------------------------------------------------
-class ValueObjectMemory : public ValueObject
-{
+class ValueObjectMemory : public ValueObject {
public:
- ~ValueObjectMemory() override;
+ ~ValueObjectMemory() override;
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- lldb::TypeSP &type_sp);
-
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- const CompilerType &ast_type);
-
- uint64_t
- GetByteSize() override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ const char *name, const Address &address,
+ lldb::TypeSP &type_sp);
- lldb::ValueType
- GetValueType() const override;
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ const char *name, const Address &address,
+ const CompilerType &ast_type);
- bool
- IsInScope() override;
+ uint64_t GetByteSize() override;
- lldb::ModuleSP
- GetModule() override;
+ ConstString GetTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ lldb::ModuleSP GetModule() override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- Address m_address; ///< The variable that this value object is based upon
- lldb::TypeSP m_type_sp;
- CompilerType m_compiler_type;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ Address m_address; ///< The variable that this value object is based upon
+ lldb::TypeSP m_type_sp;
+ CompilerType m_compiler_type;
private:
- ValueObjectMemory (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- lldb::TypeSP &type_sp);
-
- ValueObjectMemory (ExecutionContextScope *exe_scope,
- const char *name,
- const Address &address,
- const CompilerType &ast_type);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectMemory);
+ ValueObjectMemory(ExecutionContextScope *exe_scope, const char *name,
+ const Address &address, lldb::TypeSP &type_sp);
+
+ ValueObjectMemory(ExecutionContextScope *exe_scope, const char *name,
+ const Address &address, const CompilerType &ast_type);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectMemory);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Tue Sep 6 15:57:50 2016
@@ -14,9 +14,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -24,171 +24,146 @@ namespace lldb_private {
// A ValueObject that contains a root variable that may or may not
// have children.
//----------------------------------------------------------------------
-class ValueObjectRegisterContext : public ValueObject
-{
+class ValueObjectRegisterContext : public ValueObject {
public:
- ~ValueObjectRegisterContext() override;
+ ~ValueObjectRegisterContext() override;
+
+ uint64_t GetByteSize() override;
- uint64_t
- GetByteSize() override;
+ lldb::ValueType GetValueType() const override {
+ return lldb::eValueTypeRegisterSet;
+ }
- lldb::ValueType
- GetValueType() const override
- {
- return lldb::eValueTypeRegisterSet;
- }
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
+ ConstString GetTypeName() override;
- size_t
- CalculateNumChildren(uint32_t max) override;
+ ConstString GetQualifiedTypeName() override;
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
+ ConstString GetDisplayTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
- lldb::RegisterContextSP m_reg_ctx_sp;
+ lldb::RegisterContextSP m_reg_ctx_sp;
private:
- ValueObjectRegisterContext (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectRegisterContext);
+ ValueObjectRegisterContext(ValueObject &parent,
+ lldb::RegisterContextSP ®_ctx_sp);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterContext);
};
-class ValueObjectRegisterSet : public ValueObject
-{
+class ValueObjectRegisterSet : public ValueObject {
public:
- ~ValueObjectRegisterSet() override;
+ ~ValueObjectRegisterSet() override;
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP ®_ctx_sp,
+ uint32_t set_idx);
- uint64_t
- GetByteSize() override;
+ uint64_t GetByteSize() override;
- lldb::ValueType
- GetValueType() const override
- {
- return lldb::eValueTypeRegisterSet;
- }
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- ValueObject *
- CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index) override;
-
- lldb::ValueObjectSP
- GetChildMemberWithName(const ConstString &name, bool can_create) override;
+ lldb::ValueType GetValueType() const override {
+ return lldb::eValueTypeRegisterSet;
+ }
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
+ int32_t synthetic_index) override;
+
+ lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ bool can_create) override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- lldb::RegisterContextSP m_reg_ctx_sp;
- const RegisterSet *m_reg_set;
- uint32_t m_reg_set_idx;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ lldb::RegisterContextSP m_reg_ctx_sp;
+ const RegisterSet *m_reg_set;
+ uint32_t m_reg_set_idx;
private:
- friend class ValueObjectRegisterContext;
+ friend class ValueObjectRegisterContext;
- ValueObjectRegisterSet (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
+ ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectRegisterSet);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterSet);
};
-class ValueObjectRegister : public ValueObject
-{
+class ValueObjectRegister : public ValueObject {
public:
- ~ValueObjectRegister() override;
+ ~ValueObjectRegister() override;
+
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP ®_ctx_sp,
+ uint32_t reg_num);
+
+ uint64_t GetByteSize() override;
+
+ lldb::ValueType GetValueType() const override {
+ return lldb::eValueTypeRegister;
+ }
+
+ ConstString GetTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
+ bool SetValueFromCString(const char *value_str, Error &error) override;
- uint64_t
- GetByteSize() override;
+ bool SetData(DataExtractor &data, Error &error) override;
- lldb::ValueType
- GetValueType() const override
- {
- return lldb::eValueTypeRegister;
- }
-
- ConstString
- GetTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- bool
- SetData(DataExtractor &data, Error &error) override;
-
- bool
- ResolveValue(Scalar &scalar) override;
-
- void
- GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
- GetExpressionPathFormat epformat = eGetExpressionPathFormatDereferencePointers) override;
+ bool ResolveValue(Scalar &scalar) override;
+
+ void
+ GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
+ GetExpressionPathFormat epformat =
+ eGetExpressionPathFormatDereferencePointers) override;
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- lldb::RegisterContextSP m_reg_ctx_sp;
- RegisterInfo m_reg_info;
- RegisterValue m_reg_value;
- ConstString m_type_name;
- CompilerType m_compiler_type;
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ lldb::RegisterContextSP m_reg_ctx_sp;
+ RegisterInfo m_reg_info;
+ RegisterValue m_reg_value;
+ ConstString m_type_name;
+ CompilerType m_compiler_type;
private:
- void
- ConstructObject (uint32_t reg_num);
-
- friend class ValueObjectRegisterSet;
-
- ValueObjectRegister (ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
- ValueObjectRegister (ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
-
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectRegister);
+ void ConstructObject(uint32_t reg_num);
+
+ friend class ValueObjectRegisterSet;
+
+ ValueObjectRegister(ValueObject &parent, lldb::RegisterContextSP ®_ctx_sp,
+ uint32_t reg_num);
+ ValueObjectRegister(ExecutionContextScope *exe_scope,
+ lldb::RegisterContextSP ®_ctx_sp, uint32_t reg_num);
+
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectRegister);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Tue Sep 6 15:57:50 2016
@@ -29,185 +29,134 @@ namespace lldb_private {
// but you can bind it to any source of synthetic information and have
// it behave accordingly
//----------------------------------------------------------------------
-class ValueObjectSynthetic : public ValueObject
-{
+class ValueObjectSynthetic : public ValueObject {
public:
- ~ValueObjectSynthetic() override;
+ ~ValueObjectSynthetic() override;
+
+ uint64_t GetByteSize() override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ bool MightHaveChildren() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
+
+ lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ bool can_create) override;
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+ lldb::ValueObjectSP
+ GetDynamicValue(lldb::DynamicValueType valueType) override;
+
+ bool IsInScope() override;
+
+ bool HasSyntheticValue() override { return false; }
+
+ bool IsSynthetic() override { return true; }
+
+ void CalculateSyntheticValue(bool use_synthetic) override {}
+
+ bool IsDynamic() override {
+ return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
+ }
+
+ lldb::ValueObjectSP GetStaticValue() override {
+ return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
+ }
+
+ virtual lldb::DynamicValueType GetDynamicValueType() {
+ return ((m_parent != nullptr) ? m_parent->GetDynamicValueType()
+ : lldb::eNoDynamicValues);
+ }
+
+ ValueObject *GetParent() override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ const ValueObject *GetParent() const override {
+ return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
+ }
+
+ lldb::ValueObjectSP GetNonSyntheticValue() override;
+
+ bool CanProvideValue() override;
+
+ bool DoesProvideSyntheticValue() override {
+ return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
+ }
+
+ bool GetIsConstant() const override { return false; }
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ void SetFormat(lldb::Format format) override;
+
+ lldb::LanguageType GetPreferredDisplayLanguage() override;
+
+ void SetPreferredDisplayLanguage(lldb::LanguageType);
+
+ bool IsSyntheticChildrenGenerated() override;
+
+ void SetSyntheticChildrenGenerated(bool b) override;
+
+ bool GetDeclaration(Declaration &decl) override;
+
+ uint64_t GetLanguageFlags() override;
+
+ void SetLanguageFlags(uint64_t flags) override;
- uint64_t
- GetByteSize() override;
-
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- bool
- MightHaveChildren() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(size_t idx, bool can_create) override;
-
- lldb::ValueObjectSP
- GetChildMemberWithName(const ConstString &name, bool can_create) override;
-
- size_t
- GetIndexOfChildWithName(const ConstString &name) override;
-
- lldb::ValueObjectSP
- GetDynamicValue(lldb::DynamicValueType valueType) override;
-
- bool
- IsInScope() override;
-
- bool
- HasSyntheticValue() override
- {
- return false;
- }
-
- bool
- IsSynthetic() override
- {
- return true;
- }
-
- void
- CalculateSyntheticValue(bool use_synthetic) override
- {
- }
-
- bool
- IsDynamic() override
- {
- return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
- }
-
- lldb::ValueObjectSP
- GetStaticValue() override
- {
- return ((m_parent != nullptr) ? m_parent->GetStaticValue() : GetSP());
- }
-
- virtual lldb::DynamicValueType
- GetDynamicValueType ()
- {
- return ((m_parent != nullptr) ? m_parent->GetDynamicValueType() : lldb::eNoDynamicValues);
- }
-
- ValueObject *
- GetParent() override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- const ValueObject *
- GetParent() const override
- {
- return ((m_parent != nullptr) ? m_parent->GetParent() : nullptr);
- }
-
- lldb::ValueObjectSP
- GetNonSyntheticValue() override;
-
- bool
- CanProvideValue() override;
-
- bool
- DoesProvideSyntheticValue() override
- {
- return (UpdateValueIfNeeded(), m_provides_value == eLazyBoolYes);
- }
-
- bool
- GetIsConstant() const override
- {
- return false;
- }
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- void
- SetFormat(lldb::Format format) override;
-
- lldb::LanguageType
- GetPreferredDisplayLanguage() override;
-
- void
- SetPreferredDisplayLanguage (lldb::LanguageType);
-
- bool
- IsSyntheticChildrenGenerated () override;
-
- void
- SetSyntheticChildrenGenerated (bool b) override;
-
- bool
- GetDeclaration(Declaration &decl) override;
-
- uint64_t
- GetLanguageFlags () override;
-
- void
- SetLanguageFlags (uint64_t flags) override;
-
protected:
- bool
- UpdateValue() override;
-
- LazyBool
- CanUpdateWithInvalidExecutionContext() override
- {
- return eLazyBoolYes;
- }
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- virtual void
- CreateSynthFilter ();
-
- // we need to hold on to the SyntheticChildren because someone might delete the type binding while we are alive
- lldb::SyntheticChildrenSP m_synth_sp;
- std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
-
- typedef ThreadSafeSTLMap<uint32_t, ValueObject*> ByIndexMap;
- typedef ThreadSafeSTLMap<const char*, uint32_t> NameToIndexMap;
- typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
-
- typedef ByIndexMap::iterator ByIndexIterator;
- typedef NameToIndexMap::iterator NameToIndexIterator;
-
- ByIndexMap m_children_byindex;
- NameToIndexMap m_name_toindex;
- uint32_t m_synthetic_children_count; // FIXME use the ValueObject's ChildrenManager instead of a special purpose solution
- SyntheticChildrenCache m_synthetic_children_cache;
-
- ConstString m_parent_type_name;
-
- LazyBool m_might_have_children;
-
- LazyBool m_provides_value;
-
+ bool UpdateValue() override;
+
+ LazyBool CanUpdateWithInvalidExecutionContext() override {
+ return eLazyBoolYes;
+ }
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ virtual void CreateSynthFilter();
+
+ // we need to hold on to the SyntheticChildren because someone might delete
+ // the type binding while we are alive
+ lldb::SyntheticChildrenSP m_synth_sp;
+ std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_ap;
+
+ typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap;
+ typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap;
+ typedef ThreadSafeSTLVector<lldb::ValueObjectSP> SyntheticChildrenCache;
+
+ typedef ByIndexMap::iterator ByIndexIterator;
+ typedef NameToIndexMap::iterator NameToIndexIterator;
+
+ ByIndexMap m_children_byindex;
+ NameToIndexMap m_name_toindex;
+ uint32_t m_synthetic_children_count; // FIXME use the ValueObject's
+ // ChildrenManager instead of a special
+ // purpose solution
+ SyntheticChildrenCache m_synthetic_children_cache;
+
+ ConstString m_parent_type_name;
+
+ LazyBool m_might_have_children;
+
+ LazyBool m_provides_value;
+
private:
- friend class ValueObject;
- ValueObjectSynthetic (ValueObject &parent, lldb::SyntheticChildrenSP filter);
-
- void
- CopyValueData (ValueObject *source);
-
- DISALLOW_COPY_AND_ASSIGN (ValueObjectSynthetic);
+ friend class ValueObject;
+ ValueObjectSynthetic(ValueObject &parent, lldb::SyntheticChildrenSP filter);
+
+ void CopyValueData(ValueObject *source);
+
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Tue Sep 6 15:57:50 2016
@@ -22,75 +22,58 @@ namespace lldb_private {
// A ValueObject that contains a root variable that may or may not
// have children.
//----------------------------------------------------------------------
-class ValueObjectVariable : public ValueObject
-{
+class ValueObjectVariable : public ValueObject {
public:
- ~ValueObjectVariable() override;
+ ~ValueObjectVariable() override;
- static lldb::ValueObjectSP
- Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
+ static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
+ const lldb::VariableSP &var_sp);
- uint64_t
- GetByteSize() override;
+ uint64_t GetByteSize() override;
+
+ ConstString GetTypeName() override;
+
+ ConstString GetQualifiedTypeName() override;
+
+ ConstString GetDisplayTypeName() override;
+
+ size_t CalculateNumChildren(uint32_t max) override;
+
+ lldb::ValueType GetValueType() const override;
+
+ bool IsInScope() override;
+
+ lldb::ModuleSP GetModule() override;
+
+ SymbolContextScope *GetSymbolContextScope() override;
+
+ bool GetDeclaration(Declaration &decl) override;
+
+ const char *GetLocationAsCString() override;
+
+ bool SetValueFromCString(const char *value_str, Error &error) override;
+
+ bool SetData(DataExtractor &data, Error &error) override;
+
+ virtual lldb::VariableSP GetVariable() override { return m_variable_sp; }
- ConstString
- GetTypeName() override;
-
- ConstString
- GetQualifiedTypeName() override;
-
- ConstString
- GetDisplayTypeName() override;
-
- size_t
- CalculateNumChildren(uint32_t max) override;
-
- lldb::ValueType
- GetValueType() const override;
-
- bool
- IsInScope() override;
-
- lldb::ModuleSP
- GetModule() override;
-
- SymbolContextScope *
- GetSymbolContextScope() override;
-
- bool
- GetDeclaration(Declaration &decl) override;
-
- const char *
- GetLocationAsCString() override;
-
- bool
- SetValueFromCString(const char *value_str, Error& error) override;
-
- bool
- SetData(DataExtractor &data, Error &error) override;
-
- virtual lldb::VariableSP
- GetVariable () override
- {
- return m_variable_sp;
- }
-
protected:
- bool
- UpdateValue() override;
-
- CompilerType
- GetCompilerTypeImpl() override;
-
- lldb::VariableSP m_variable_sp; ///< The variable that this value object is based upon
- Value m_resolved_value; ///< The value that DWARFExpression resolves this variable to before we patch it up
-
+ bool UpdateValue() override;
+
+ CompilerType GetCompilerTypeImpl() override;
+
+ lldb::VariableSP
+ m_variable_sp; ///< The variable that this value object is based upon
+ Value m_resolved_value; ///< The value that DWARFExpression resolves this
+ ///variable to before we patch it up
+
private:
- ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp);
- //------------------------------------------------------------------
- // For ValueObject only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ValueObjectVariable);
+ ValueObjectVariable(ExecutionContextScope *exe_scope,
+ const lldb::VariableSP &var_sp);
+ //------------------------------------------------------------------
+ // For ValueObject only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable);
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/dwarf.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/dwarf.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/dwarf.h (original)
+++ lldb/trunk/include/lldb/Core/dwarf.h Tue Sep 6 15:57:50 2016
@@ -20,24 +20,28 @@
// and stuff them in our default namespace
using namespace llvm::dwarf;
-typedef uint32_t dw_uleb128_t;
-typedef int32_t dw_sleb128_t;
-typedef uint16_t dw_attr_t;
-typedef uint16_t dw_form_t;
-typedef uint16_t dw_tag_t;
-typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for any addresses in the compile units that get parsed
+typedef uint32_t dw_uleb128_t;
+typedef int32_t dw_sleb128_t;
+typedef uint16_t dw_attr_t;
+typedef uint16_t dw_form_t;
+typedef uint16_t dw_tag_t;
+typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for
+ // any addresses in the compile units that get
+ // parsed
#ifdef DWARFUTILS_DWARF64
-#define DWARF_REF_ADDR_SIZE 8
-typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any offset into the file
+#define DWARF_REF_ADDR_SIZE 8
+typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any
+ // offset into the file
#else
-#define DWARF_REF_ADDR_SIZE 4
-typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any offset into the file
+#define DWARF_REF_ADDR_SIZE 4
+typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any
+ // offset into the file
#endif
/* Constants */
-#define DW_INVALID_OFFSET (~(dw_offset_t)0)
-#define DW_INVALID_INDEX 0xFFFFFFFFul
+#define DW_INVALID_OFFSET (~(dw_offset_t)0)
+#define DW_INVALID_INDEX 0xFFFFFFFFul
// #define DW_ADDR_none 0x0
@@ -48,20 +52,34 @@ typedef uint32_t dw_offset_t; // D
//// them in executable files anywhere.
//// These constants fit between DW_OP_lo_user (0xe0) and DW_OP_hi_user (0xff).
//
-//#define DW_OP_APPLE_array_ref 0xEE // first pops index, then pops array; pushes array[index]
-//#define DW_OP_APPLE_extern 0xEF // ULEB128 index of external object (i.e., an entity from the program that was used in the expression)
-#define DW_OP_APPLE_uninit 0xF0 // This is actually generated by some apple compilers in locations lists
-//#define DW_OP_APPLE_assign 0xF1 // pops value off and assigns it to second item on stack (2nd item must have assignable context)
-//#define DW_OP_APPLE_address_of 0xF2 // gets the address of the top stack item (top item must be a variable, or have value_type that is an address already)
-//#define DW_OP_APPLE_value_of 0xF3 // pops the value off the stack and pushes the value of that object (top item must be a variable, or expression local)
-//#define DW_OP_APPLE_deref_type 0xF4 // gets the address of the top stack item (top item must be a variable, or a clang type)
+//#define DW_OP_APPLE_array_ref 0xEE // first pops index, then pops array;
+//pushes array[index]
+//#define DW_OP_APPLE_extern 0xEF // ULEB128 index of external object
+//(i.e., an entity from the program that was used in the expression)
+#define DW_OP_APPLE_uninit \
+ 0xF0 // This is actually generated by some apple compilers in locations lists
+//#define DW_OP_APPLE_assign 0xF1 // pops value off and assigns it to
+//second item on stack (2nd item must have assignable context)
+//#define DW_OP_APPLE_address_of 0xF2 // gets the address of the top stack
+//item (top item must be a variable, or have value_type that is an address
+//already)
+//#define DW_OP_APPLE_value_of 0xF3 // pops the value off the stack and
+//pushes the value of that object (top item must be a variable, or expression
+//local)
+//#define DW_OP_APPLE_deref_type 0xF4 // gets the address of the top stack
+//item (top item must be a variable, or a clang type)
//#define DW_OP_APPLE_expr_local 0xF5 // ULEB128 expression local index
-//#define DW_OP_APPLE_constf 0xF6 // 1 byte float size, followed by constant float data
-//#define DW_OP_APPLE_scalar_cast 0xF7 // Cast top of stack to 2nd in stack's type leaving all items in place
-//#define DW_OP_APPLE_clang_cast 0xF8 // pointer size clang::Type * off the stack and cast top stack item to this type
-//#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack, ok if the stack is empty
-//#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and returns an error (no args)
+//#define DW_OP_APPLE_constf 0xF6 // 1 byte float size, followed by
+//constant float data
+//#define DW_OP_APPLE_scalar_cast 0xF7 // Cast top of stack to 2nd in stack's
+//type leaving all items in place
+//#define DW_OP_APPLE_clang_cast 0xF8 // pointer size clang::Type * off the
+//stack and cast top stack item to this type
+//#define DW_OP_APPLE_clear 0xFE // clears the entire expression stack,
+//ok if the stack is empty
+//#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and
+//returns an error (no args)
typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> DWARFRangeList;
-#endif // DebugBase_dwarf_h_
+#endif // DebugBase_dwarf_h_
Modified: lldb/trunk/include/lldb/DataFormatters/CXXFunctionPointer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/CXXFunctionPointer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/CXXFunctionPointer.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/CXXFunctionPointer.h Tue Sep 6 15:57:50 2016
@@ -13,11 +13,10 @@
#include "lldb/lldb-forward.h"
namespace lldb_private {
- namespace formatters
- {
- bool
- CXXFunctionPointerSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options);
- } // namespace formatters
+namespace formatters {
+bool CXXFunctionPointerSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_CXXFunctionPointer_h_
Modified: lldb/trunk/include/lldb/DataFormatters/DataVisualization.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DataVisualization.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/DataVisualization.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DataVisualization.h Tue Sep 6 15:57:50 2016
@@ -23,151 +23,124 @@ namespace lldb_private {
// this class is the high-level front-end of LLDB Data Visualization
// code in FormatManager.h/cpp is the low-level implementation of this feature
-// clients should refer to this class as the entry-point into the data formatters
+// clients should refer to this class as the entry-point into the data
+// formatters
// unless they have a good reason to bypass this and go to the backend
-class DataVisualization
-{
+class DataVisualization {
public:
- // use this call to force the FM to consider itself updated even when there is no apparent reason for that
- static void
- ForceUpdate();
-
- static uint32_t
- GetCurrentRevision ();
-
- static bool
- ShouldPrintAsOneLiner (ValueObject& valobj);
-
- static lldb::TypeFormatImplSP
- GetFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeFormatImplSP
- GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- static lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeSummaryImplSP
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
-
+ // use this call to force the FM to consider itself updated even when there is
+ // no apparent reason for that
+ static void ForceUpdate();
+
+ static uint32_t GetCurrentRevision();
+
+ static bool ShouldPrintAsOneLiner(ValueObject &valobj);
+
+ static lldb::TypeFormatImplSP GetFormat(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
+
+ static lldb::TypeFormatImplSP
+ GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ static lldb::TypeSummaryImplSP
+ GetSummaryFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
+
+ static lldb::TypeSummaryImplSP
+ GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
+
#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
+ static lldb::SyntheticChildrenSP
+ GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
- static lldb::TypeFilterImplSP
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
+
+ static lldb::TypeFilterImplSP
+ GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
#ifndef LLDB_DISABLE_PYTHON
- static lldb::ScriptedSyntheticChildrenSP
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+ static lldb::ScriptedSyntheticChildrenSP
+ GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
+
#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildren(ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ static lldb::SyntheticChildrenSP
+ GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
#endif
-
- static lldb::TypeValidatorImplSP
- GetValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- static lldb::TypeValidatorImplSP
- GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- static bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr);
-
- class NamedSummaryFormats
- {
- public:
- static bool
- GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry);
-
- static void
- Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry);
-
- static bool
- Delete (const ConstString &type);
-
- static void
- Clear ();
-
- static void
- ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback);
-
- static uint32_t
- GetCount ();
- };
-
- class Categories
- {
- public:
- static bool
- GetCategory (const ConstString &category,
- lldb::TypeCategoryImplSP &entry,
- bool allow_create = true);
-
- static bool
- GetCategory (lldb::LanguageType language,
- lldb::TypeCategoryImplSP &entry);
-
- static void
- Add (const ConstString &category);
-
- static bool
- Delete (const ConstString &category);
-
- static void
- Clear ();
-
- static void
- Clear (const ConstString &category);
-
- static void
- Enable (const ConstString& category,
- TypeCategoryMap::Position = TypeCategoryMap::Default);
-
- static void
- Enable (lldb::LanguageType lang_type);
-
- static void
- Disable (const ConstString& category);
-
- static void
- Disable (lldb::LanguageType lang_type);
-
- static void
- Enable (const lldb::TypeCategoryImplSP& category,
- TypeCategoryMap::Position = TypeCategoryMap::Default);
-
- static void
- Disable (const lldb::TypeCategoryImplSP& category);
-
- static void
- EnableStar ();
-
- static void
- DisableStar ();
-
- static void
- ForEach (TypeCategoryMap::ForEachCallback callback);
-
- static uint32_t
- GetCount ();
-
- static lldb::TypeCategoryImplSP
- GetCategoryAtIndex (size_t);
- };
+
+ static lldb::TypeValidatorImplSP
+ GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
+
+ static lldb::TypeValidatorImplSP
+ GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ static bool
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items =
+ TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true, const char **matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
+
+ class NamedSummaryFormats {
+ public:
+ static bool GetSummaryFormat(const ConstString &type,
+ lldb::TypeSummaryImplSP &entry);
+
+ static void Add(const ConstString &type,
+ const lldb::TypeSummaryImplSP &entry);
+
+ static bool Delete(const ConstString &type);
+
+ static void Clear();
+
+ static void
+ ForEach(std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)>
+ callback);
+
+ static uint32_t GetCount();
+ };
+
+ class Categories {
+ public:
+ static bool GetCategory(const ConstString &category,
+ lldb::TypeCategoryImplSP &entry,
+ bool allow_create = true);
+
+ static bool GetCategory(lldb::LanguageType language,
+ lldb::TypeCategoryImplSP &entry);
+
+ static void Add(const ConstString &category);
+
+ static bool Delete(const ConstString &category);
+
+ static void Clear();
+
+ static void Clear(const ConstString &category);
+
+ static void Enable(const ConstString &category,
+ TypeCategoryMap::Position = TypeCategoryMap::Default);
+
+ static void Enable(lldb::LanguageType lang_type);
+
+ static void Disable(const ConstString &category);
+
+ static void Disable(lldb::LanguageType lang_type);
+
+ static void Enable(const lldb::TypeCategoryImplSP &category,
+ TypeCategoryMap::Position = TypeCategoryMap::Default);
+
+ static void Disable(const lldb::TypeCategoryImplSP &category);
+
+ static void EnableStar();
+
+ static void DisableStar();
+
+ static void ForEach(TypeCategoryMap::ForEachCallback callback);
+
+ static uint32_t GetCount();
+
+ static lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t);
+ };
};
} // namespace lldb_private
-#endif// lldb_DataVisualization_h_
+#endif // lldb_DataVisualization_h_
Modified: lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/DumpValueObjectOptions.h Tue Sep 6 15:57:50 2016
@@ -23,165 +23,125 @@
#include <string>
namespace lldb_private {
-
-class DumpValueObjectOptions
-{
+
+class DumpValueObjectOptions {
public:
- struct PointerDepth
- {
- enum class Mode
- {
- Always,
- Formatters,
- Default,
- Never
- } m_mode;
- uint32_t m_count;
-
- PointerDepth
- operator --() const
- {
- if (m_count > 0)
- return PointerDepth {m_mode,m_count-1};
- return PointerDepth {m_mode,m_count};
- }
-
- bool
- CanAllowExpansion () const;
-
- bool
- CanAllowExpansion (bool is_root,
- TypeSummaryImpl* entry,
- ValueObject *valobj,
- const std::string& summary);
- };
-
- typedef std::function<bool(ConstString,
- ConstString,
- const DumpValueObjectOptions &,
- Stream&)> DeclPrintingHelper;
-
- static const DumpValueObjectOptions
- DefaultOptions()
- {
- static DumpValueObjectOptions g_default_options;
-
- return g_default_options;
+ struct PointerDepth {
+ enum class Mode { Always, Formatters, Default, Never } m_mode;
+ uint32_t m_count;
+
+ PointerDepth operator--() const {
+ if (m_count > 0)
+ return PointerDepth{m_mode, m_count - 1};
+ return PointerDepth{m_mode, m_count};
}
-
- DumpValueObjectOptions();
-
- DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
-
- DumpValueObjectOptions (ValueObject& valobj);
-
- DumpValueObjectOptions&
- SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never,0});
-
- DumpValueObjectOptions&
- SetMaximumDepth(uint32_t depth = 0);
-
- DumpValueObjectOptions&
- SetDeclPrintingHelper(DeclPrintingHelper helper);
-
- DumpValueObjectOptions&
- SetShowTypes(bool show = false);
-
- DumpValueObjectOptions&
- SetShowLocation(bool show = false);
-
- DumpValueObjectOptions&
- SetUseObjectiveC(bool use = false);
-
- DumpValueObjectOptions&
- SetShowSummary(bool show = true);
-
- DumpValueObjectOptions&
- SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues);
-
- DumpValueObjectOptions&
- SetUseSyntheticValue(bool use_synthetic = true);
-
- DumpValueObjectOptions&
- SetScopeChecked(bool check = true);
-
- DumpValueObjectOptions&
- SetFlatOutput(bool flat = false);
-
- DumpValueObjectOptions&
- SetOmitSummaryDepth(uint32_t depth = 0);
-
- DumpValueObjectOptions&
- SetIgnoreCap(bool ignore = false);
-
- DumpValueObjectOptions&
- SetRawDisplay();
-
- DumpValueObjectOptions&
- SetFormat (lldb::Format format = lldb::eFormatDefault);
-
- DumpValueObjectOptions&
- SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP());
-
- DumpValueObjectOptions&
- SetRootValueObjectName(const char* name = nullptr);
-
- DumpValueObjectOptions&
- SetHideRootType (bool hide_root_type = false);
-
- DumpValueObjectOptions&
- SetHideName (bool hide_name = false);
-
- DumpValueObjectOptions&
- SetHideValue (bool hide_value = false);
-
- DumpValueObjectOptions&
- SetHidePointerValue (bool hide = false);
-
- DumpValueObjectOptions&
- SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
-
- DumpValueObjectOptions&
- SetRunValidator (bool run = true);
-
- DumpValueObjectOptions&
- SetUseTypeDisplayName (bool dis = false);
-
- DumpValueObjectOptions&
- SetAllowOnelinerMode (bool oneliner = false);
-
- DumpValueObjectOptions&
- SetRevealEmptyAggregates (bool reveal = true);
-
- DumpValueObjectOptions&
- SetElementCount (uint32_t element_count = 0);
+
+ bool CanAllowExpansion() const;
+
+ bool CanAllowExpansion(bool is_root, TypeSummaryImpl *entry,
+ ValueObject *valobj, const std::string &summary);
+ };
+
+ typedef std::function<bool(ConstString, ConstString,
+ const DumpValueObjectOptions &, Stream &)>
+ DeclPrintingHelper;
+
+ static const DumpValueObjectOptions DefaultOptions() {
+ static DumpValueObjectOptions g_default_options;
+
+ return g_default_options;
+ }
+
+ DumpValueObjectOptions();
+
+ DumpValueObjectOptions(const DumpValueObjectOptions &rhs) = default;
+
+ DumpValueObjectOptions(ValueObject &valobj);
+
+ DumpValueObjectOptions &
+ SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
+
+ DumpValueObjectOptions &SetMaximumDepth(uint32_t depth = 0);
+
+ DumpValueObjectOptions &SetDeclPrintingHelper(DeclPrintingHelper helper);
+
+ DumpValueObjectOptions &SetShowTypes(bool show = false);
+
+ DumpValueObjectOptions &SetShowLocation(bool show = false);
+
+ DumpValueObjectOptions &SetUseObjectiveC(bool use = false);
+
+ DumpValueObjectOptions &SetShowSummary(bool show = true);
+
+ DumpValueObjectOptions &
+ SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues);
+
+ DumpValueObjectOptions &SetUseSyntheticValue(bool use_synthetic = true);
+
+ DumpValueObjectOptions &SetScopeChecked(bool check = true);
+
+ DumpValueObjectOptions &SetFlatOutput(bool flat = false);
+
+ DumpValueObjectOptions &SetOmitSummaryDepth(uint32_t depth = 0);
+
+ DumpValueObjectOptions &SetIgnoreCap(bool ignore = false);
+
+ DumpValueObjectOptions &SetRawDisplay();
+
+ DumpValueObjectOptions &SetFormat(lldb::Format format = lldb::eFormatDefault);
+
+ DumpValueObjectOptions &
+ SetSummary(lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP());
+
+ DumpValueObjectOptions &SetRootValueObjectName(const char *name = nullptr);
+
+ DumpValueObjectOptions &SetHideRootType(bool hide_root_type = false);
+
+ DumpValueObjectOptions &SetHideName(bool hide_name = false);
+
+ DumpValueObjectOptions &SetHideValue(bool hide_value = false);
+
+ DumpValueObjectOptions &SetHidePointerValue(bool hide = false);
+
+ DumpValueObjectOptions &SetVariableFormatDisplayLanguage(
+ lldb::LanguageType lang = lldb::eLanguageTypeUnknown);
+
+ DumpValueObjectOptions &SetRunValidator(bool run = true);
+
+ DumpValueObjectOptions &SetUseTypeDisplayName(bool dis = false);
+
+ DumpValueObjectOptions &SetAllowOnelinerMode(bool oneliner = false);
+
+ DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true);
+
+ DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0);
public:
- uint32_t m_max_depth = UINT32_MAX;
- lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
- uint32_t m_omit_summary_depth = 0;
- lldb::Format m_format = lldb::eFormatDefault;
- lldb::TypeSummaryImplSP m_summary_sp;
- std::string m_root_valobj_name;
- lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
- PointerDepth m_max_ptr_depth;
- DeclPrintingHelper m_decl_printing_helper;
- uint32_t m_element_count = 0;
- bool m_use_synthetic : 1;
- bool m_scope_already_checked : 1;
- bool m_flat_output : 1;
- bool m_ignore_cap : 1;
- bool m_show_types : 1;
- bool m_show_location : 1;
- bool m_use_objc : 1;
- bool m_hide_root_type : 1;
- bool m_hide_name : 1;
- bool m_hide_value : 1;
- bool m_run_validator : 1;
- bool m_use_type_display_name : 1;
- bool m_allow_oneliner_mode : 1;
- bool m_hide_pointer_value : 1;
- bool m_reveal_empty_aggregates : 1;
+ uint32_t m_max_depth = UINT32_MAX;
+ lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
+ uint32_t m_omit_summary_depth = 0;
+ lldb::Format m_format = lldb::eFormatDefault;
+ lldb::TypeSummaryImplSP m_summary_sp;
+ std::string m_root_valobj_name;
+ lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
+ PointerDepth m_max_ptr_depth;
+ DeclPrintingHelper m_decl_printing_helper;
+ uint32_t m_element_count = 0;
+ bool m_use_synthetic : 1;
+ bool m_scope_already_checked : 1;
+ bool m_flat_output : 1;
+ bool m_ignore_cap : 1;
+ bool m_show_types : 1;
+ bool m_show_location : 1;
+ bool m_use_objc : 1;
+ bool m_hide_root_type : 1;
+ bool m_hide_name : 1;
+ bool m_hide_value : 1;
+ bool m_run_validator : 1;
+ bool m_use_type_display_name : 1;
+ bool m_allow_oneliner_mode : 1;
+ bool m_hide_pointer_value : 1;
+ bool m_reveal_empty_aggregates : 1;
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/DataFormatters/FormatCache.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatCache.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatCache.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatCache.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- FormatCache.h ---------------------------------------------*- C++ -*-===//
+//===-- FormatCache.h ---------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,121 +18,95 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
-class FormatCache
-{
+class FormatCache {
private:
- struct Entry
- {
- private:
- bool m_format_cached : 1;
- bool m_summary_cached : 1;
- bool m_synthetic_cached : 1;
- bool m_validator_cached : 1;
-
- lldb::TypeFormatImplSP m_format_sp;
- lldb::TypeSummaryImplSP m_summary_sp;
- lldb::SyntheticChildrenSP m_synthetic_sp;
- lldb::TypeValidatorImplSP m_validator_sp;
- public:
- Entry ();
- Entry (lldb::TypeFormatImplSP);
- Entry (lldb::TypeSummaryImplSP);
- Entry (lldb::SyntheticChildrenSP);
- Entry (lldb::TypeValidatorImplSP);
- Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP,lldb::TypeValidatorImplSP);
-
- bool
- IsFormatCached ();
-
- bool
- IsSummaryCached ();
-
- bool
- IsSyntheticCached ();
-
- bool
- IsValidatorCached ();
-
- lldb::TypeFormatImplSP
- GetFormat ();
-
- lldb::TypeSummaryImplSP
- GetSummary ();
-
- lldb::SyntheticChildrenSP
- GetSynthetic ();
-
- lldb::TypeValidatorImplSP
- GetValidator ();
-
- void
- SetFormat (lldb::TypeFormatImplSP);
-
- void
- SetSummary (lldb::TypeSummaryImplSP);
-
- void
- SetSynthetic (lldb::SyntheticChildrenSP);
-
- void
- SetValidator (lldb::TypeValidatorImplSP);
- };
- typedef std::map<ConstString,Entry> CacheMap;
- CacheMap m_map;
- std::recursive_mutex m_mutex;
-
- uint64_t m_cache_hits;
- uint64_t m_cache_misses;
-
- Entry&
- GetEntry (const ConstString& type);
-
+ struct Entry {
+ private:
+ bool m_format_cached : 1;
+ bool m_summary_cached : 1;
+ bool m_synthetic_cached : 1;
+ bool m_validator_cached : 1;
+
+ lldb::TypeFormatImplSP m_format_sp;
+ lldb::TypeSummaryImplSP m_summary_sp;
+ lldb::SyntheticChildrenSP m_synthetic_sp;
+ lldb::TypeValidatorImplSP m_validator_sp;
+
+ public:
+ Entry();
+ Entry(lldb::TypeFormatImplSP);
+ Entry(lldb::TypeSummaryImplSP);
+ Entry(lldb::SyntheticChildrenSP);
+ Entry(lldb::TypeValidatorImplSP);
+ Entry(lldb::TypeFormatImplSP, lldb::TypeSummaryImplSP,
+ lldb::SyntheticChildrenSP, lldb::TypeValidatorImplSP);
+
+ bool IsFormatCached();
+
+ bool IsSummaryCached();
+
+ bool IsSyntheticCached();
+
+ bool IsValidatorCached();
+
+ lldb::TypeFormatImplSP GetFormat();
+
+ lldb::TypeSummaryImplSP GetSummary();
+
+ lldb::SyntheticChildrenSP GetSynthetic();
+
+ lldb::TypeValidatorImplSP GetValidator();
+
+ void SetFormat(lldb::TypeFormatImplSP);
+
+ void SetSummary(lldb::TypeSummaryImplSP);
+
+ void SetSynthetic(lldb::SyntheticChildrenSP);
+
+ void SetValidator(lldb::TypeValidatorImplSP);
+ };
+ typedef std::map<ConstString, Entry> CacheMap;
+ CacheMap m_map;
+ std::recursive_mutex m_mutex;
+
+ uint64_t m_cache_hits;
+ uint64_t m_cache_misses;
+
+ Entry &GetEntry(const ConstString &type);
+
public:
- FormatCache ();
-
- bool
- GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
-
- bool
- GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
-
- bool
- GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
-
- bool
- GetValidator (const ConstString& type,lldb::TypeValidatorImplSP& summary_sp);
-
- void
- SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp);
-
- void
- SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp);
-
- void
- SetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp);
-
- void
- SetValidator (const ConstString& type,lldb::TypeValidatorImplSP& synthetic_sp);
-
- void
- Clear ();
-
- uint64_t
- GetCacheHits ()
- {
- return m_cache_hits;
- }
-
- uint64_t
- GetCacheMisses ()
- {
- return m_cache_misses;
- }
+ FormatCache();
+
+ bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
+
+ bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
+
+ bool GetSynthetic(const ConstString &type,
+ lldb::SyntheticChildrenSP &synthetic_sp);
+
+ bool GetValidator(const ConstString &type,
+ lldb::TypeValidatorImplSP &summary_sp);
+
+ void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
+
+ void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
+
+ void SetSynthetic(const ConstString &type,
+ lldb::SyntheticChildrenSP &synthetic_sp);
+
+ void SetValidator(const ConstString &type,
+ lldb::TypeValidatorImplSP &synthetic_sp);
+
+ void Clear();
+
+ uint64_t GetCacheHits() { return m_cache_hits; }
+
+ uint64_t GetCacheMisses() { return m_cache_misses; }
};
} // namespace lldb_private
-#endif // lldb_FormatCache_h_
+#endif // lldb_FormatCache_h_
Modified: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatClasses.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatClasses.h Tue Sep 6 15:57:50 2016
@@ -19,222 +19,160 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
#include "lldb/DataFormatters/TypeFormat.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/DataFormatters/TypeValidator.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
class HardcodedFormatters {
public:
- template <typename FormatterType>
- using HardcodedFormatterFinder = std::function<typename FormatterType::SharedPointer (lldb_private::ValueObject&,
- lldb::DynamicValueType,
- FormatManager&)>;
-
- template <typename FormatterType>
- using HardcodedFormatterFinders = std::vector<HardcodedFormatterFinder<FormatterType>>;
-
- typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
- typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
- typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
- typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
+ template <typename FormatterType>
+ using HardcodedFormatterFinder =
+ std::function<typename FormatterType::SharedPointer(
+ lldb_private::ValueObject &, lldb::DynamicValueType,
+ FormatManager &)>;
+
+ template <typename FormatterType>
+ using HardcodedFormatterFinders =
+ std::vector<HardcodedFormatterFinder<FormatterType>>;
+
+ typedef HardcodedFormatterFinders<TypeFormatImpl> HardcodedFormatFinder;
+ typedef HardcodedFormatterFinders<TypeSummaryImpl> HardcodedSummaryFinder;
+ typedef HardcodedFormatterFinders<SyntheticChildren> HardcodedSyntheticFinder;
+ typedef HardcodedFormatterFinders<TypeValidatorImpl> HardcodedValidatorFinder;
};
-class FormattersMatchCandidate
-{
+class FormattersMatchCandidate {
public:
- FormattersMatchCandidate (ConstString name,
- uint32_t reason,
- bool strip_ptr,
- bool strip_ref,
- bool strip_tydef) :
- m_type_name(name),
- m_reason(reason),
- m_stripped_pointer(strip_ptr),
- m_stripped_reference(strip_ref),
- m_stripped_typedef(strip_tydef)
- {
- }
-
- ~FormattersMatchCandidate() = default;
+ FormattersMatchCandidate(ConstString name, uint32_t reason, bool strip_ptr,
+ bool strip_ref, bool strip_tydef)
+ : m_type_name(name), m_reason(reason), m_stripped_pointer(strip_ptr),
+ m_stripped_reference(strip_ref), m_stripped_typedef(strip_tydef) {}
+
+ ~FormattersMatchCandidate() = default;
+
+ ConstString GetTypeName() const { return m_type_name; }
+
+ uint32_t GetReason() const { return m_reason; }
+
+ bool DidStripPointer() const { return m_stripped_pointer; }
+
+ bool DidStripReference() const { return m_stripped_reference; }
+
+ bool DidStripTypedef() const { return m_stripped_typedef; }
+
+ template <class Formatter>
+ bool IsMatch(const std::shared_ptr<Formatter> &formatter_sp) const {
+ if (!formatter_sp)
+ return false;
+ if (formatter_sp->Cascades() == false && DidStripTypedef())
+ return false;
+ if (formatter_sp->SkipsPointers() && DidStripPointer())
+ return false;
+ if (formatter_sp->SkipsReferences() && DidStripReference())
+ return false;
+ return true;
+ }
- ConstString
- GetTypeName () const
- {
- return m_type_name;
- }
-
- uint32_t
- GetReason () const
- {
- return m_reason;
- }
-
- bool
- DidStripPointer () const
- {
- return m_stripped_pointer;
- }
-
- bool
- DidStripReference () const
- {
- return m_stripped_reference;
- }
-
- bool
- DidStripTypedef () const
- {
- return m_stripped_typedef;
- }
-
- template <class Formatter>
- bool
- IsMatch (const std::shared_ptr<Formatter>& formatter_sp) const
- {
- if (!formatter_sp)
- return false;
- if (formatter_sp->Cascades() == false && DidStripTypedef())
- return false;
- if (formatter_sp->SkipsPointers() && DidStripPointer())
- return false;
- if (formatter_sp->SkipsReferences() && DidStripReference())
- return false;
- return true;
- }
-
private:
- ConstString m_type_name;
- uint32_t m_reason;
- bool m_stripped_pointer;
- bool m_stripped_reference;
- bool m_stripped_typedef;
+ ConstString m_type_name;
+ uint32_t m_reason;
+ bool m_stripped_pointer;
+ bool m_stripped_reference;
+ bool m_stripped_typedef;
};
typedef std::vector<FormattersMatchCandidate> FormattersMatchVector;
typedef std::vector<lldb::LanguageType> CandidateLanguagesVector;
-class FormattersMatchData
-{
+class FormattersMatchData {
public:
- FormattersMatchData (ValueObject&,
- lldb::DynamicValueType);
-
- FormattersMatchVector
- GetMatchesVector ();
-
- ConstString
- GetTypeForCache ();
-
- CandidateLanguagesVector
- GetCandidateLanguages ();
-
- ValueObject&
- GetValueObject ();
-
- lldb::DynamicValueType
- GetDynamicValueType ();
-
+ FormattersMatchData(ValueObject &, lldb::DynamicValueType);
+
+ FormattersMatchVector GetMatchesVector();
+
+ ConstString GetTypeForCache();
+
+ CandidateLanguagesVector GetCandidateLanguages();
+
+ ValueObject &GetValueObject();
+
+ lldb::DynamicValueType GetDynamicValueType();
+
private:
- ValueObject& m_valobj;
- lldb::DynamicValueType m_dynamic_value_type;
- std::pair<FormattersMatchVector,bool> m_formatters_match_vector;
- ConstString m_type_for_cache;
- CandidateLanguagesVector m_candidate_languages;
+ ValueObject &m_valobj;
+ lldb::DynamicValueType m_dynamic_value_type;
+ std::pair<FormattersMatchVector, bool> m_formatters_match_vector;
+ ConstString m_type_for_cache;
+ CandidateLanguagesVector m_candidate_languages;
};
-
-class TypeNameSpecifierImpl
-{
+
+class TypeNameSpecifierImpl {
public:
- TypeNameSpecifierImpl() :
- m_is_regex(false),
- m_type()
- {
- }
-
- TypeNameSpecifierImpl (const char* name, bool is_regex) :
- m_is_regex(is_regex),
- m_type()
- {
- if (name)
- m_type.m_type_name.assign(name);
- }
-
- // if constructing with a given type, is_regex cannot be true since we are
- // giving an exact type to match
- TypeNameSpecifierImpl (lldb::TypeSP type) :
- m_is_regex(false),
- m_type()
- {
- if (type)
- {
- m_type.m_type_name.assign(type->GetName().GetCString());
- m_type.m_type_pair.SetType(type);
- }
- }
+ TypeNameSpecifierImpl() : m_is_regex(false), m_type() {}
+
+ TypeNameSpecifierImpl(const char *name, bool is_regex)
+ : m_is_regex(is_regex), m_type() {
+ if (name)
+ m_type.m_type_name.assign(name);
+ }
+
+ // if constructing with a given type, is_regex cannot be true since we are
+ // giving an exact type to match
+ TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() {
+ if (type) {
+ m_type.m_type_name.assign(type->GetName().GetCString());
+ m_type.m_type_pair.SetType(type);
+ }
+ }
+
+ TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false), m_type() {
+ if (type.IsValid()) {
+ m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
+ m_type.m_type_pair.SetType(type);
+ }
+ }
+
+ const char *GetName() {
+ if (m_type.m_type_name.size())
+ return m_type.m_type_name.c_str();
+ return nullptr;
+ }
+
+ lldb::TypeSP GetTypeSP() {
+ if (m_type.m_type_pair.IsValid())
+ return m_type.m_type_pair.GetTypeSP();
+ return lldb::TypeSP();
+ }
+
+ CompilerType GetCompilerType() {
+ if (m_type.m_type_pair.IsValid())
+ return m_type.m_type_pair.GetCompilerType();
+ return CompilerType();
+ }
+
+ bool IsRegex() { return m_is_regex; }
- TypeNameSpecifierImpl (CompilerType type) :
- m_is_regex(false),
- m_type()
- {
- if (type.IsValid())
- {
- m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
- m_type.m_type_pair.SetType(type);
- }
- }
-
- const char*
- GetName()
- {
- if (m_type.m_type_name.size())
- return m_type.m_type_name.c_str();
- return nullptr;
- }
-
- lldb::TypeSP
- GetTypeSP ()
- {
- if (m_type.m_type_pair.IsValid())
- return m_type.m_type_pair.GetTypeSP();
- return lldb::TypeSP();
- }
-
- CompilerType
- GetCompilerType ()
- {
- if (m_type.m_type_pair.IsValid())
- return m_type.m_type_pair.GetCompilerType();
- return CompilerType();
- }
-
- bool
- IsRegex()
- {
- return m_is_regex;
- }
-
private:
- bool m_is_regex;
- // this works better than TypeAndOrName because the latter only wraps a TypeSP
- // whereas TypePair can also be backed by a CompilerType
- struct TypeOrName
- {
- std::string m_type_name;
- TypePair m_type_pair;
- };
- TypeOrName m_type;
+ bool m_is_regex;
+ // this works better than TypeAndOrName because the latter only wraps a TypeSP
+ // whereas TypePair can also be backed by a CompilerType
+ struct TypeOrName {
+ std::string m_type_name;
+ TypePair m_type_pair;
+ };
+ TypeOrName m_type;
private:
- DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
+ DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
};
-
+
} // namespace lldb_private
#endif // lldb_FormatClasses_h_
Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Tue Sep 6 15:57:50 2016
@@ -20,8 +20,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormatCache.h"
#include "lldb/DataFormatters/FormatClasses.h"
@@ -31,306 +31,240 @@
#include "lldb/DataFormatters/TypeCategoryMap.h"
namespace lldb_private {
-
-// this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
+
+// this file (and its. cpp) contain the low-level implementation of LLDB Data
+// Visualization
// class DataVisualization is the high-level front-end of this feature
-// clients should refer to that class as the entry-point into the data formatters
-// unless they have a good reason to bypass it and prefer to use this file's objects directly
+// clients should refer to that class as the entry-point into the data
+// formatters
+// unless they have a good reason to bypass it and prefer to use this file's
+// objects directly
+
+class FormatManager : public IFormatChangeListener {
+ typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
+ typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
-class FormatManager : public IFormatChangeListener
-{
- typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap;
- typedef TypeCategoryMap::MapType::iterator CategoryMapIterator;
public:
- typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer> LanguageCategories;
-
- FormatManager();
-
- ~FormatManager() override = default;
-
- NamedSummariesMap&
- GetNamedSummaryContainer ()
- {
- return m_named_summaries_map;
- }
-
- void
- EnableCategory (const ConstString& category_name,
- TypeCategoryMap::Position pos = TypeCategoryMap::Default)
- {
- EnableCategory(category_name,
- pos,
- std::initializer_list<lldb::LanguageType>());
- }
+ typedef std::map<lldb::LanguageType, LanguageCategory::UniquePointer>
+ LanguageCategories;
- void
- EnableCategory (const ConstString& category_name,
- TypeCategoryMap::Position pos,
- lldb::LanguageType lang)
- {
- std::initializer_list<lldb::LanguageType> langs = {lang};
- EnableCategory(category_name,
- pos,
- langs);
- }
-
- void
- EnableCategory (const ConstString& category_name,
- TypeCategoryMap::Position pos = TypeCategoryMap::Default,
- std::initializer_list<lldb::LanguageType> langs = {})
- {
- TypeCategoryMap::ValueSP category_sp;
- if (m_categories_map.Get(category_name, category_sp) && category_sp)
- {
- m_categories_map.Enable(category_sp, pos);
- for (const lldb::LanguageType lang : langs)
- category_sp->AddLanguage(lang);
- }
- }
-
- void
- DisableCategory (const ConstString& category_name)
- {
- m_categories_map.Disable(category_name);
- }
-
- void
- EnableCategory (const lldb::TypeCategoryImplSP& category,
- TypeCategoryMap::Position pos = TypeCategoryMap::Default)
- {
- m_categories_map.Enable(category,
- pos);
- }
-
- void
- DisableCategory (const lldb::TypeCategoryImplSP& category)
- {
- m_categories_map.Disable(category);
- }
-
- void
- EnableAllCategories ();
-
- void
- DisableAllCategories ();
-
- bool
- DeleteCategory (const ConstString& category_name)
- {
- return m_categories_map.Delete(category_name);
- }
-
- void
- ClearCategories ()
- {
- return m_categories_map.Clear();
- }
-
- uint32_t
- GetCategoriesCount ()
- {
- return m_categories_map.GetCount();
- }
-
- lldb::TypeCategoryImplSP
- GetCategoryAtIndex (size_t index)
- {
- return m_categories_map.GetAtIndex(index);
- }
-
- void
- ForEachCategory (TypeCategoryMap::ForEachCallback callback);
-
- lldb::TypeCategoryImplSP
- GetCategory(const char* category_name = nullptr,
- bool can_create = true)
- {
- if (!category_name)
- return GetCategory(m_default_category_name);
- return GetCategory(ConstString(category_name));
+ FormatManager();
+
+ ~FormatManager() override = default;
+
+ NamedSummariesMap &GetNamedSummaryContainer() {
+ return m_named_summaries_map;
+ }
+
+ void
+ EnableCategory(const ConstString &category_name,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default) {
+ EnableCategory(category_name, pos,
+ std::initializer_list<lldb::LanguageType>());
+ }
+
+ void EnableCategory(const ConstString &category_name,
+ TypeCategoryMap::Position pos, lldb::LanguageType lang) {
+ std::initializer_list<lldb::LanguageType> langs = {lang};
+ EnableCategory(category_name, pos, langs);
+ }
+
+ void EnableCategory(const ConstString &category_name,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default,
+ std::initializer_list<lldb::LanguageType> langs = {}) {
+ TypeCategoryMap::ValueSP category_sp;
+ if (m_categories_map.Get(category_name, category_sp) && category_sp) {
+ m_categories_map.Enable(category_sp, pos);
+ for (const lldb::LanguageType lang : langs)
+ category_sp->AddLanguage(lang);
}
-
- lldb::TypeCategoryImplSP
- GetCategory (const ConstString& category_name,
- bool can_create = true);
-
- lldb::TypeFormatImplSP
- GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeSummaryImplSP
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
+ }
+
+ void DisableCategory(const ConstString &category_name) {
+ m_categories_map.Disable(category_name);
+ }
+
+ void
+ EnableCategory(const lldb::TypeCategoryImplSP &category,
+ TypeCategoryMap::Position pos = TypeCategoryMap::Default) {
+ m_categories_map.Enable(category, pos);
+ }
+
+ void DisableCategory(const lldb::TypeCategoryImplSP &category) {
+ m_categories_map.Disable(category);
+ }
+
+ void EnableAllCategories();
+
+ void DisableAllCategories();
- lldb::TypeFilterImplSP
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
+ bool DeleteCategory(const ConstString &category_name) {
+ return m_categories_map.Delete(category_name);
+ }
+
+ void ClearCategories() { return m_categories_map.Clear(); }
+
+ uint32_t GetCategoriesCount() { return m_categories_map.GetCount(); }
+
+ lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t index) {
+ return m_categories_map.GetAtIndex(index);
+ }
+
+ void ForEachCategory(TypeCategoryMap::ForEachCallback callback);
+
+ lldb::TypeCategoryImplSP GetCategory(const char *category_name = nullptr,
+ bool can_create = true) {
+ if (!category_name)
+ return GetCategory(m_default_category_name);
+ return GetCategory(ConstString(category_name));
+ }
+
+ lldb::TypeCategoryImplSP GetCategory(const ConstString &category_name,
+ bool can_create = true);
+
+ lldb::TypeFormatImplSP
+ GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ lldb::TypeSummaryImplSP
+ GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ lldb::TypeFilterImplSP
+ GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
#ifndef LLDB_DISABLE_PYTHON
- lldb::ScriptedSyntheticChildrenSP
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+ lldb::ScriptedSyntheticChildrenSP
+ GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
+
#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp);
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
- lldb::TypeValidatorImplSP
- GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeFormatImplSP
- GetFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+
+ lldb::TypeValidatorImplSP
+ GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ lldb::TypeFormatImplSP GetFormat(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::TypeSummaryImplSP GetSummaryFormat(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
#endif
-
- lldb::TypeValidatorImplSP
- GetValidator (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic);
-
- bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr)
- {
- return m_categories_map.AnyMatches(type_name,
- items,
- only_enabled,
- matching_category,
- matching_type);
- }
- static bool
- GetFormatFromCString (const char *format_cstr,
- bool partial_match_ok,
- lldb::Format &format);
-
- static char
- GetFormatAsFormatChar (lldb::Format format);
-
- static const char *
- GetFormatAsCString (lldb::Format format);
-
- // if the user tries to add formatters for, say, "struct Foo"
- // those will not match any type because of the way we strip qualifiers from typenames
- // this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
- // and strips the unnecessary qualifier
- static ConstString
- GetValidTypeName (const ConstString& type);
-
- // when DataExtractor dumps a vectorOfT, it uses a predefined format for each item
- // this method returns it, or eFormatInvalid if vector_format is not a vectorOf
- static lldb::Format
- GetSingleItemFormat (lldb::Format vector_format);
-
- // this returns true if the ValueObjectPrinter is *highly encouraged*
- // to actually represent this ValueObject in one-liner format
- // If this object has a summary formatter, however, we should not
- // try and do one-lining, just let the summary do the right thing
- bool
- ShouldPrintAsOneLiner (ValueObject& valobj);
-
- void
- Changed () override;
-
- uint32_t
- GetCurrentRevision () override
- {
- return m_last_revision;
- }
+ lldb::TypeValidatorImplSP GetValidator(ValueObject &valobj,
+ lldb::DynamicValueType use_dynamic);
- static FormattersMatchVector
- GetPossibleMatches (ValueObject& valobj,
- lldb::DynamicValueType use_dynamic)
- {
- FormattersMatchVector matches;
- GetPossibleMatches (valobj,
- valobj.GetCompilerType(),
- lldb_private::eFormatterChoiceCriterionDirectChoice,
- use_dynamic,
- matches,
- false,
- false,
- false,
- true);
- return matches;
- }
-
- static ConstString
- GetTypeForCache (ValueObject&, lldb::DynamicValueType);
-
- LanguageCategory*
- GetCategoryForLanguage (lldb::LanguageType lang_type);
+ bool
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items =
+ TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true, const char **matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr) {
+ return m_categories_map.AnyMatches(type_name, items, only_enabled,
+ matching_category, matching_type);
+ }
+
+ static bool GetFormatFromCString(const char *format_cstr,
+ bool partial_match_ok, lldb::Format &format);
+
+ static char GetFormatAsFormatChar(lldb::Format format);
+
+ static const char *GetFormatAsCString(lldb::Format format);
+
+ // if the user tries to add formatters for, say, "struct Foo"
+ // those will not match any type because of the way we strip qualifiers from
+ // typenames
+ // this method looks for the case where the user is adding a
+ // "class","struct","enum" or "union" Foo
+ // and strips the unnecessary qualifier
+ static ConstString GetValidTypeName(const ConstString &type);
+
+ // when DataExtractor dumps a vectorOfT, it uses a predefined format for each
+ // item
+ // this method returns it, or eFormatInvalid if vector_format is not a
+ // vectorOf
+ static lldb::Format GetSingleItemFormat(lldb::Format vector_format);
+
+ // this returns true if the ValueObjectPrinter is *highly encouraged*
+ // to actually represent this ValueObject in one-liner format
+ // If this object has a summary formatter, however, we should not
+ // try and do one-lining, just let the summary do the right thing
+ bool ShouldPrintAsOneLiner(ValueObject &valobj);
+
+ void Changed() override;
+
+ uint32_t GetCurrentRevision() override { return m_last_revision; }
+
+ static FormattersMatchVector
+ GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) {
+ FormattersMatchVector matches;
+ GetPossibleMatches(valobj, valobj.GetCompilerType(),
+ lldb_private::eFormatterChoiceCriterionDirectChoice,
+ use_dynamic, matches, false, false, false, true);
+ return matches;
+ }
+
+ static ConstString GetTypeForCache(ValueObject &, lldb::DynamicValueType);
+
+ LanguageCategory *GetCategoryForLanguage(lldb::LanguageType lang_type);
- static std::vector<lldb::LanguageType>
- GetCandidateLanguages (lldb::LanguageType lang_type);
+ static std::vector<lldb::LanguageType>
+ GetCandidateLanguages(lldb::LanguageType lang_type);
private:
- static std::vector<lldb::LanguageType>
- GetCandidateLanguages (ValueObject& valobj);
-
- static void
- GetPossibleMatches (ValueObject& valobj,
- CompilerType compiler_type,
- uint32_t reason,
- lldb::DynamicValueType use_dynamic,
- FormattersMatchVector& entries,
- bool did_strip_ptr,
- bool did_strip_ref,
- bool did_strip_typedef,
- bool root_level = false);
-
- std::atomic<uint32_t> m_last_revision;
- FormatCache m_format_cache;
- std::recursive_mutex m_language_categories_mutex;
- LanguageCategories m_language_categories_map;
- NamedSummariesMap m_named_summaries_map;
- TypeCategoryMap m_categories_map;
-
- ConstString m_default_category_name;
- ConstString m_system_category_name;
- ConstString m_vectortypes_category_name;
-
- lldb::TypeFormatImplSP
- GetHardcodedFormat (FormattersMatchData&);
-
- lldb::TypeSummaryImplSP
- GetHardcodedSummaryFormat (FormattersMatchData&);
-
- lldb::SyntheticChildrenSP
- GetHardcodedSyntheticChildren (FormattersMatchData&);
-
- lldb::TypeValidatorImplSP
- GetHardcodedValidator (FormattersMatchData&);
-
- TypeCategoryMap&
- GetCategories ()
- {
- return m_categories_map;
- }
-
- // These functions are meant to initialize formatters that are very low-level/global in nature
- // and do not naturally belong in any language. The intent is that most formatters go in
- // language-specific categories. Eventually, the runtimes should also be allowed to vend their
- // own formatters, and then one could put formatters that depend on specific library load events
- // in the language runtimes, on an as-needed basis
- void
- LoadSystemFormatters ();
-
- void
- LoadVectorFormatters ();
-
- friend class FormattersMatchData;
+ static std::vector<lldb::LanguageType>
+ GetCandidateLanguages(ValueObject &valobj);
+
+ static void GetPossibleMatches(ValueObject &valobj,
+ CompilerType compiler_type, uint32_t reason,
+ lldb::DynamicValueType use_dynamic,
+ FormattersMatchVector &entries,
+ bool did_strip_ptr, bool did_strip_ref,
+ bool did_strip_typedef,
+ bool root_level = false);
+
+ std::atomic<uint32_t> m_last_revision;
+ FormatCache m_format_cache;
+ std::recursive_mutex m_language_categories_mutex;
+ LanguageCategories m_language_categories_map;
+ NamedSummariesMap m_named_summaries_map;
+ TypeCategoryMap m_categories_map;
+
+ ConstString m_default_category_name;
+ ConstString m_system_category_name;
+ ConstString m_vectortypes_category_name;
+
+ lldb::TypeFormatImplSP GetHardcodedFormat(FormattersMatchData &);
+
+ lldb::TypeSummaryImplSP GetHardcodedSummaryFormat(FormattersMatchData &);
+
+ lldb::SyntheticChildrenSP
+ GetHardcodedSyntheticChildren(FormattersMatchData &);
+
+ lldb::TypeValidatorImplSP GetHardcodedValidator(FormattersMatchData &);
+
+ TypeCategoryMap &GetCategories() { return m_categories_map; }
+
+ // These functions are meant to initialize formatters that are very
+ // low-level/global in nature
+ // and do not naturally belong in any language. The intent is that most
+ // formatters go in
+ // language-specific categories. Eventually, the runtimes should also be
+ // allowed to vend their
+ // own formatters, and then one could put formatters that depend on specific
+ // library load events
+ // in the language runtimes, on an as-needed basis
+ void LoadSystemFormatters();
+
+ void LoadVectorFormatters();
+
+ friend class FormattersMatchData;
};
-
+
} // namespace lldb_private
-
+
#endif // lldb_FormatManager_h_
Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Tue Sep 6 15:57:50 2016
@@ -33,411 +33,318 @@
#include "lldb/Utility/StringLexer.h"
namespace lldb_private {
-
-class IFormatChangeListener
-{
+
+class IFormatChangeListener {
public:
- virtual
- ~IFormatChangeListener() = default;
+ virtual ~IFormatChangeListener() = default;
- virtual void
- Changed () = 0;
+ virtual void Changed() = 0;
- virtual uint32_t
- GetCurrentRevision () = 0;
+ virtual uint32_t GetCurrentRevision() = 0;
};
-
+
// if the user tries to add formatters for, say, "struct Foo"
-// those will not match any type because of the way we strip qualifiers from typenames
-// this method looks for the case where the user is adding a "class","struct","enum" or "union" Foo
+// those will not match any type because of the way we strip qualifiers from
+// typenames
+// this method looks for the case where the user is adding a
+// "class","struct","enum" or "union" Foo
// and strips the unnecessary qualifier
-static inline ConstString
-GetValidTypeName_Impl (const ConstString& type)
-{
- if (type.IsEmpty())
- return type;
-
- std::string type_cstr(type.AsCString());
- lldb_utility::StringLexer type_lexer(type_cstr);
-
- type_lexer.AdvanceIf("class ");
- type_lexer.AdvanceIf("enum ");
- type_lexer.AdvanceIf("struct ");
- type_lexer.AdvanceIf("union ");
-
- while (type_lexer.NextIf({' ','\t','\v','\f'}).first)
- ;
-
- return ConstString(type_lexer.GetUnlexed());
-}
+static inline ConstString GetValidTypeName_Impl(const ConstString &type) {
+ if (type.IsEmpty())
+ return type;
+
+ std::string type_cstr(type.AsCString());
+ lldb_utility::StringLexer type_lexer(type_cstr);
+
+ type_lexer.AdvanceIf("class ");
+ type_lexer.AdvanceIf("enum ");
+ type_lexer.AdvanceIf("struct ");
+ type_lexer.AdvanceIf("union ");
-template<typename KeyType, typename ValueType>
-class FormattersContainer;
+ while (type_lexer.NextIf({' ', '\t', '\v', '\f'}).first)
+ ;
-template<typename KeyType, typename ValueType>
-class FormatMap
-{
-public:
- typedef typename ValueType::SharedPointer ValueSP;
- typedef std::map<KeyType, ValueSP> MapType;
- typedef typename MapType::iterator MapIterator;
- typedef std::function<bool(KeyType, const ValueSP&)> ForEachCallback;
-
- FormatMap(IFormatChangeListener *lst) : m_map(), m_map_mutex(), listener(lst) {}
-
- void
- Add(KeyType name, const ValueSP &entry)
- {
- if (listener)
- entry->GetRevision() = listener->GetCurrentRevision();
- else
- entry->GetRevision() = 0;
-
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- m_map[name] = entry;
- if (listener)
- listener->Changed();
- }
-
- bool
- Delete(KeyType name)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- m_map.erase(name);
- if (listener)
- listener->Changed();
- return true;
- }
+ return ConstString(type_lexer.GetUnlexed());
+}
- void
- Clear()
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- m_map.clear();
- if (listener)
- listener->Changed();
- }
+template <typename KeyType, typename ValueType> class FormattersContainer;
- bool
- Get(KeyType name, ValueSP &entry)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.find(name);
- if (iter == m_map.end())
- return false;
- entry = iter->second;
- return true;
+template <typename KeyType, typename ValueType> class FormatMap {
+public:
+ typedef typename ValueType::SharedPointer ValueSP;
+ typedef std::map<KeyType, ValueSP> MapType;
+ typedef typename MapType::iterator MapIterator;
+ typedef std::function<bool(KeyType, const ValueSP &)> ForEachCallback;
+
+ FormatMap(IFormatChangeListener *lst)
+ : m_map(), m_map_mutex(), listener(lst) {}
+
+ void Add(KeyType name, const ValueSP &entry) {
+ if (listener)
+ entry->GetRevision() = listener->GetCurrentRevision();
+ else
+ entry->GetRevision() = 0;
+
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ m_map[name] = entry;
+ if (listener)
+ listener->Changed();
+ }
+
+ bool Delete(KeyType name) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ m_map.erase(name);
+ if (listener)
+ listener->Changed();
+ return true;
+ }
+
+ void Clear() {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ m_map.clear();
+ if (listener)
+ listener->Changed();
+ }
+
+ bool Get(KeyType name, ValueSP &entry) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.find(name);
+ if (iter == m_map.end())
+ return false;
+ entry = iter->second;
+ return true;
+ }
+
+ void ForEach(ForEachCallback callback) {
+ if (callback) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator pos, end = m_map.end();
+ for (pos = m_map.begin(); pos != end; pos++) {
+ KeyType type = pos->first;
+ if (!callback(type, pos->second))
+ break;
+ }
+ }
+ }
+
+ uint32_t GetCount() { return m_map.size(); }
+
+ ValueSP GetValueAtIndex(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.begin();
+ MapIterator end = m_map.end();
+ while (index > 0) {
+ iter++;
+ index--;
+ if (end == iter)
+ return ValueSP();
+ }
+ return iter->second;
+ }
+
+ KeyType GetKeyAtIndex(size_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
+ MapIterator iter = m_map.begin();
+ MapIterator end = m_map.end();
+ while (index > 0) {
+ iter++;
+ index--;
+ if (end == iter)
+ return KeyType();
}
+ return iter->first;
+ }
- void
- ForEach(ForEachCallback callback)
- {
- if (callback)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator pos, end = m_map.end();
- for (pos = m_map.begin(); pos != end; pos++)
- {
- KeyType type = pos->first;
- if (!callback(type, pos->second))
- break;
- }
- }
- }
+protected:
+ MapType m_map;
+ std::recursive_mutex m_map_mutex;
+ IFormatChangeListener *listener;
- uint32_t
- GetCount ()
- {
- return m_map.size();
- }
+ MapType &map() { return m_map; }
- ValueSP
- GetValueAtIndex(size_t index)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (index > 0)
- {
- iter++;
- index--;
- if (end == iter)
- return ValueSP();
- }
- return iter->second;
- }
+ std::recursive_mutex &mutex() { return m_map_mutex; }
- KeyType
- GetKeyAtIndex(size_t index)
- {
- std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- MapIterator iter = m_map.begin();
- MapIterator end = m_map.end();
- while (index > 0)
- {
- iter++;
- index--;
- if (end == iter)
- return KeyType();
- }
- return iter->first;
- }
+ friend class FormattersContainer<KeyType, ValueType>;
+ friend class FormatManager;
+};
+template <typename KeyType, typename ValueType> class FormattersContainer {
protected:
- MapType m_map;
- std::recursive_mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType&
- map ()
- {
- return m_map;
- }
-
- std::recursive_mutex &
- mutex()
- {
- return m_map_mutex;
- }
+ typedef FormatMap<KeyType, ValueType> BackEndType;
- friend class FormattersContainer<KeyType, ValueType>;
- friend class FormatManager;
-};
-
-template<typename KeyType, typename ValueType>
-class FormattersContainer
-{
-protected:
- typedef FormatMap<KeyType,ValueType> BackEndType;
-
public:
- typedef typename BackEndType::MapType MapType;
- typedef typename MapType::iterator MapIterator;
- typedef typename MapType::key_type MapKeyType;
- typedef typename MapType::mapped_type MapValueType;
- typedef typename BackEndType::ForEachCallback ForEachCallback;
- typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType> > SharedPointer;
-
- friend class TypeCategoryImpl;
-
- FormattersContainer(std::string name,
- IFormatChangeListener* lst) :
- m_format_map(lst),
- m_name(name)
- {
- }
-
- void
- Add (const MapKeyType &type, const MapValueType& entry)
- {
- Add_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- bool
- Delete (ConstString type)
- {
- return Delete_Impl(type, static_cast<KeyType*>(nullptr));
- }
-
- bool
- Get(ValueObject& valobj,
- MapValueType& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t* why = nullptr)
- {
- uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
- CompilerType ast_type(valobj.GetCompilerType());
- bool ret = Get(valobj, ast_type, entry, use_dynamic, value);
- if (ret)
- entry = MapValueType(entry);
- else
- entry = MapValueType();
- if (why)
- *why = value;
- return ret;
- }
-
- bool
- Get (ConstString type, MapValueType& entry)
- {
- return Get_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- bool
- GetExact (ConstString type, MapValueType& entry)
- {
- return GetExact_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- MapValueType
- GetAtIndex (size_t index)
- {
- return m_format_map.GetValueAtIndex(index);
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex (size_t index)
- {
- return GetTypeNameSpecifierAtIndex_Impl(index, static_cast<KeyType*>(nullptr));
- }
-
- void
- Clear ()
- {
- m_format_map.Clear();
- }
-
- void
- ForEach (ForEachCallback callback)
- {
- m_format_map.ForEach(callback);
- }
-
- uint32_t
- GetCount ()
- {
- return m_format_map.GetCount();
- }
-
-protected:
- BackEndType m_format_map;
- std::string m_name;
-
- DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
-
- void
- Add_Impl (const MapKeyType &type, const MapValueType& entry, lldb::RegularExpressionSP *dummy)
- {
- m_format_map.Add(type,entry);
- }
+ typedef typename BackEndType::MapType MapType;
+ typedef typename MapType::iterator MapIterator;
+ typedef typename MapType::key_type MapKeyType;
+ typedef typename MapType::mapped_type MapValueType;
+ typedef typename BackEndType::ForEachCallback ForEachCallback;
+ typedef typename std::shared_ptr<FormattersContainer<KeyType, ValueType>>
+ SharedPointer;
+
+ friend class TypeCategoryImpl;
+
+ FormattersContainer(std::string name, IFormatChangeListener *lst)
+ : m_format_map(lst), m_name(name) {}
+
+ void Add(const MapKeyType &type, const MapValueType &entry) {
+ Add_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ bool Delete(ConstString type) {
+ return Delete_Impl(type, static_cast<KeyType *>(nullptr));
+ }
+
+ bool Get(ValueObject &valobj, MapValueType &entry,
+ lldb::DynamicValueType use_dynamic, uint32_t *why = nullptr) {
+ uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
+ CompilerType ast_type(valobj.GetCompilerType());
+ bool ret = Get(valobj, ast_type, entry, use_dynamic, value);
+ if (ret)
+ entry = MapValueType(entry);
+ else
+ entry = MapValueType();
+ if (why)
+ *why = value;
+ return ret;
+ }
+
+ bool Get(ConstString type, MapValueType &entry) {
+ return Get_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ bool GetExact(ConstString type, MapValueType &entry) {
+ return GetExact_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ MapValueType GetAtIndex(size_t index) {
+ return m_format_map.GetValueAtIndex(index);
+ }
+
+ lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierAtIndex(size_t index) {
+ return GetTypeNameSpecifierAtIndex_Impl(index,
+ static_cast<KeyType *>(nullptr));
+ }
- void Add_Impl (const ConstString &type, const MapValueType& entry, ConstString *dummy)
- {
- m_format_map.Add(GetValidTypeName_Impl(type), entry);
- }
+ void Clear() { m_format_map.Clear(); }
- bool
- Delete_Impl (ConstString type, ConstString *dummy)
- {
- return m_format_map.Delete(type);
- }
+ void ForEach(ForEachCallback callback) { m_format_map.ForEach(callback); }
- bool
- Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy)
- {
- std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (::strcmp(type.AsCString(), regex->GetText()) == 0)
- {
- m_format_map.map().erase(pos);
- if (m_format_map.listener)
- m_format_map.listener->Changed();
- return true;
- }
- }
- return false;
- }
+ uint32_t GetCount() { return m_format_map.GetCount(); }
- bool
- Get_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
- {
- return m_format_map.Get(type, entry);
- }
+protected:
+ BackEndType m_format_map;
+ std::string m_name;
- bool
- GetExact_Impl (ConstString type, MapValueType& entry, ConstString *dummy)
- {
- return Get_Impl(type, entry, static_cast<KeyType*>(nullptr));
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (size_t index, ConstString *dummy)
- {
- ConstString key = m_format_map.GetKeyAtIndex(index);
- if (key)
- return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(key.AsCString(),
- false));
- else
- return lldb::TypeNameSpecifierImplSP();
- }
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierAtIndex_Impl (size_t index, lldb::RegularExpressionSP *dummy)
- {
- lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
- if (regex.get() == nullptr)
- return lldb::TypeNameSpecifierImplSP();
- return lldb::TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(regex->GetText(),
- true));
+ DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
+
+ void Add_Impl(const MapKeyType &type, const MapValueType &entry,
+ lldb::RegularExpressionSP *dummy) {
+ m_format_map.Add(type, entry);
+ }
+
+ void Add_Impl(const ConstString &type, const MapValueType &entry,
+ ConstString *dummy) {
+ m_format_map.Add(GetValidTypeName_Impl(type), entry);
+ }
+
+ bool Delete_Impl(ConstString type, ConstString *dummy) {
+ return m_format_map.Delete(type);
+ }
+
+ bool Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy) {
+ std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++) {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (::strcmp(type.AsCString(), regex->GetText()) == 0) {
+ m_format_map.map().erase(pos);
+ if (m_format_map.listener)
+ m_format_map.listener->Changed();
+ return true;
+ }
}
+ return false;
+ }
- bool
- Get_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy)
- {
- const char *key_cstr = key.AsCString();
- if (!key_cstr)
- return false;
- std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (regex->Execute(key_cstr))
- {
- value = pos->second;
- return true;
- }
- }
- return false;
+ bool Get_Impl(ConstString type, MapValueType &entry, ConstString *dummy) {
+ return m_format_map.Get(type, entry);
+ }
+
+ bool GetExact_Impl(ConstString type, MapValueType &entry,
+ ConstString *dummy) {
+ return Get_Impl(type, entry, static_cast<KeyType *>(nullptr));
+ }
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierAtIndex_Impl(size_t index, ConstString *dummy) {
+ ConstString key = m_format_map.GetKeyAtIndex(index);
+ if (key)
+ return lldb::TypeNameSpecifierImplSP(
+ new TypeNameSpecifierImpl(key.AsCString(), false));
+ else
+ return lldb::TypeNameSpecifierImplSP();
+ }
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierAtIndex_Impl(size_t index,
+ lldb::RegularExpressionSP *dummy) {
+ lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
+ if (regex.get() == nullptr)
+ return lldb::TypeNameSpecifierImplSP();
+ return lldb::TypeNameSpecifierImplSP(
+ new TypeNameSpecifierImpl(regex->GetText(), true));
+ }
+
+ bool Get_Impl(ConstString key, MapValueType &value,
+ lldb::RegularExpressionSP *dummy) {
+ const char *key_cstr = key.AsCString();
+ if (!key_cstr)
+ return false;
+ std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++) {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (regex->Execute(key_cstr)) {
+ value = pos->second;
+ return true;
+ }
}
+ return false;
+ }
- bool
- GetExact_Impl(ConstString key, MapValueType &value, lldb::RegularExpressionSP *dummy)
- {
- std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
- MapIterator pos, end = m_format_map.map().end();
- for (pos = m_format_map.map().begin(); pos != end; pos++)
- {
- lldb::RegularExpressionSP regex = pos->first;
- if (strcmp(regex->GetText(), key.AsCString()) == 0)
- {
- value = pos->second;
- return true;
- }
- }
- return false;
+ bool GetExact_Impl(ConstString key, MapValueType &value,
+ lldb::RegularExpressionSP *dummy) {
+ std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
+ MapIterator pos, end = m_format_map.map().end();
+ for (pos = m_format_map.map().begin(); pos != end; pos++) {
+ lldb::RegularExpressionSP regex = pos->first;
+ if (strcmp(regex->GetText(), key.AsCString()) == 0) {
+ value = pos->second;
+ return true;
+ }
}
+ return false;
+ }
- bool
- Get (const FormattersMatchVector& candidates,
- MapValueType& entry,
- uint32_t *reason)
- {
- for (const FormattersMatchCandidate& candidate : candidates)
- {
- if (Get(candidate.GetTypeName(),entry))
- {
- if (candidate.IsMatch(entry) == false)
- {
- entry.reset();
- continue;
- }
- else
- {
- if(reason)
- *reason = candidate.GetReason();
- return true;
- }
- }
+ bool Get(const FormattersMatchVector &candidates, MapValueType &entry,
+ uint32_t *reason) {
+ for (const FormattersMatchCandidate &candidate : candidates) {
+ if (Get(candidate.GetTypeName(), entry)) {
+ if (candidate.IsMatch(entry) == false) {
+ entry.reset();
+ continue;
+ } else {
+ if (reason)
+ *reason = candidate.GetReason();
+ return true;
}
- return false;
+ }
}
+ return false;
+ }
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersHelpers.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- FormattersHelpers.h --------------------------------------*- C++ -*-===//
+//===-- FormattersHelpers.h --------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,8 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-forward.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-forward.h"
#include "lldb/DataFormatters/TypeCategory.h"
#include "lldb/DataFormatters/TypeFormat.h"
@@ -23,229 +24,171 @@
#include "lldb/DataFormatters/TypeSynthetic.h"
namespace lldb_private {
- namespace formatters {
- void
- AddFormat (TypeCategoryImpl::SharedPointer category_sp,
- lldb::Format format,
- ConstString type_name,
- TypeFormatImpl::Flags flags,
- bool regex = false);
-
- void
- AddSummary(TypeCategoryImpl::SharedPointer category_sp,
- lldb::TypeSummaryImplSP summary_sp,
- ConstString type_name,
- bool regex = false);
-
- void
- AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
- const char* string,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false);
-
- void
- AddOneLineSummary (TypeCategoryImpl::SharedPointer category_sp,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
- bool regex = false);
+namespace formatters {
+void AddFormat(TypeCategoryImpl::SharedPointer category_sp, lldb::Format format,
+ ConstString type_name, TypeFormatImpl::Flags flags,
+ bool regex = false);
+
+void AddSummary(TypeCategoryImpl::SharedPointer category_sp,
+ lldb::TypeSummaryImplSP summary_sp, ConstString type_name,
+ bool regex = false);
+
+void AddStringSummary(TypeCategoryImpl::SharedPointer category_sp,
+ const char *string, ConstString type_name,
+ TypeSummaryImpl::Flags flags, bool regex = false);
-#ifndef LLDB_DISABLE_PYTHON
- void
- AddCXXSummary (TypeCategoryImpl::SharedPointer category_sp,
- CXXFunctionSummaryFormat::Callback funct,
- const char* description,
- ConstString type_name,
- TypeSummaryImpl::Flags flags,
+void AddOneLineSummary(TypeCategoryImpl::SharedPointer category_sp,
+ ConstString type_name, TypeSummaryImpl::Flags flags,
bool regex = false);
- void
- AddCXXSynthetic (TypeCategoryImpl::SharedPointer category_sp,
- CXXSyntheticChildren::CreateFrontEndCallback generator,
- const char* description,
- ConstString type_name,
- ScriptedSyntheticChildren::Flags flags,
- bool regex = false);
-
- void
- AddFilter (TypeCategoryImpl::SharedPointer category_sp,
- std::vector<std::string> children,
- const char* description,
- ConstString type_name,
- ScriptedSyntheticChildren::Flags flags,
- bool regex = false);
+#ifndef LLDB_DISABLE_PYTHON
+void AddCXXSummary(TypeCategoryImpl::SharedPointer category_sp,
+ CXXFunctionSummaryFormat::Callback funct,
+ const char *description, ConstString type_name,
+ TypeSummaryImpl::Flags flags, bool regex = false);
+
+void AddCXXSynthetic(TypeCategoryImpl::SharedPointer category_sp,
+ CXXSyntheticChildren::CreateFrontEndCallback generator,
+ const char *description, ConstString type_name,
+ ScriptedSyntheticChildren::Flags flags,
+ bool regex = false);
+
+void AddFilter(TypeCategoryImpl::SharedPointer category_sp,
+ std::vector<std::string> children, const char *description,
+ ConstString type_name, ScriptedSyntheticChildren::Flags flags,
+ bool regex = false);
#endif
- size_t
- ExtractIndexFromString (const char* item_name);
-
- lldb::addr_t
- GetArrayAddressOrPointerValue (ValueObject& valobj);
-
- time_t
- GetOSXEpoch ();
-
- struct InferiorSizedWord {
-
- InferiorSizedWord(const InferiorSizedWord& word) : ptr_size(word.ptr_size)
- {
- if (ptr_size == 4)
- thirty_two = word.thirty_two;
- else
- sixty_four = word.sixty_four;
- }
-
- InferiorSizedWord
- operator = (const InferiorSizedWord& word)
- {
- ptr_size = word.ptr_size;
- if (ptr_size == 4)
- thirty_two = word.thirty_two;
- else
- sixty_four = word.sixty_four;
- return *this;
- }
-
- InferiorSizedWord(uint64_t val, Process& process) : ptr_size(process.GetAddressByteSize())
- {
- if (ptr_size == 4)
- thirty_two = (uint32_t)val;
- else if (ptr_size == 8)
- sixty_four = val;
- else
- assert (false && "new pointer size is unknown");
- }
-
- bool
- IsNegative () const
- {
- if (ptr_size == 4)
- return ((int32_t)thirty_two) < 0;
- else
- return ((int64_t)sixty_four) < 0;
- }
-
- bool
- IsZero () const
- {
- if (ptr_size == 4)
- return thirty_two == 0;
- else
- return sixty_four == 0;
- }
-
- static InferiorSizedWord
- GetMaximum (Process& process)
- {
- if (process.GetAddressByteSize() == 4)
- return InferiorSizedWord(UINT32_MAX,4);
- else
- return InferiorSizedWord(UINT64_MAX,8);
- }
-
- InferiorSizedWord
- operator >> (int rhs) const
- {
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two >> rhs,4);
- return InferiorSizedWord(sixty_four>>rhs,8);
- }
-
- InferiorSizedWord
- operator << (int rhs) const
- {
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two << rhs,4);
- return InferiorSizedWord(sixty_four << rhs,8);
- }
-
- InferiorSizedWord
- operator & (const InferiorSizedWord& word) const
- {
- if (ptr_size != word.ptr_size)
- return InferiorSizedWord(0,ptr_size);
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two & word.thirty_two,4);
- return InferiorSizedWord(sixty_four & word.sixty_four,8);
- }
-
- InferiorSizedWord
- operator & (int x) const
- {
- if (ptr_size == 4)
- return InferiorSizedWord(thirty_two & x,4);
- return InferiorSizedWord(sixty_four & x,8);
- }
-
- size_t
- GetBitSize () const
- {
- return ptr_size << 3;
- }
-
- size_t
- GetByteSize () const
- {
- return ptr_size;
- }
-
- uint64_t
- GetValue () const
- {
- if (ptr_size == 4)
- return (uint64_t)thirty_two;
- return sixty_four;
- }
-
- InferiorSizedWord
- SignExtend () const
- {
- if (ptr_size == 4)
- return InferiorSizedWord ((int32_t)thirty_two,4);
- return InferiorSizedWord((int64_t)sixty_four,8);
- }
-
- uint8_t*
- CopyToBuffer (uint8_t* buffer) const
- {
- if (ptr_size == 4)
- {
- memcpy(buffer, &thirty_two, 4);
- return buffer + 4;
- }
- else
- {
- memcpy(buffer, &sixty_four, 8);
- return buffer + 8;
- }
- }
-
- DataExtractor
- GetAsData (lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const
- {
- if (ptr_size == 4)
- return DataExtractor(&thirty_two, 4, byte_order, 4);
- else
- return DataExtractor(&sixty_four, 8, byte_order, 8);
- }
-
- private:
-
- InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz)
- {
- if (ptr_size == 4)
- thirty_two = (uint32_t)val;
- else
- sixty_four = val;
- }
-
- size_t ptr_size;
- union {
- uint32_t thirty_two;
- uint64_t sixty_four;
- };
- };
- } // namespace formatters
+size_t ExtractIndexFromString(const char *item_name);
+
+lldb::addr_t GetArrayAddressOrPointerValue(ValueObject &valobj);
+
+time_t GetOSXEpoch();
+
+struct InferiorSizedWord {
+
+ InferiorSizedWord(const InferiorSizedWord &word) : ptr_size(word.ptr_size) {
+ if (ptr_size == 4)
+ thirty_two = word.thirty_two;
+ else
+ sixty_four = word.sixty_four;
+ }
+
+ InferiorSizedWord operator=(const InferiorSizedWord &word) {
+ ptr_size = word.ptr_size;
+ if (ptr_size == 4)
+ thirty_two = word.thirty_two;
+ else
+ sixty_four = word.sixty_four;
+ return *this;
+ }
+
+ InferiorSizedWord(uint64_t val, Process &process)
+ : ptr_size(process.GetAddressByteSize()) {
+ if (ptr_size == 4)
+ thirty_two = (uint32_t)val;
+ else if (ptr_size == 8)
+ sixty_four = val;
+ else
+ assert(false && "new pointer size is unknown");
+ }
+
+ bool IsNegative() const {
+ if (ptr_size == 4)
+ return ((int32_t)thirty_two) < 0;
+ else
+ return ((int64_t)sixty_four) < 0;
+ }
+
+ bool IsZero() const {
+ if (ptr_size == 4)
+ return thirty_two == 0;
+ else
+ return sixty_four == 0;
+ }
+
+ static InferiorSizedWord GetMaximum(Process &process) {
+ if (process.GetAddressByteSize() == 4)
+ return InferiorSizedWord(UINT32_MAX, 4);
+ else
+ return InferiorSizedWord(UINT64_MAX, 8);
+ }
+
+ InferiorSizedWord operator>>(int rhs) const {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two >> rhs, 4);
+ return InferiorSizedWord(sixty_four >> rhs, 8);
+ }
+
+ InferiorSizedWord operator<<(int rhs) const {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two << rhs, 4);
+ return InferiorSizedWord(sixty_four << rhs, 8);
+ }
+
+ InferiorSizedWord operator&(const InferiorSizedWord &word) const {
+ if (ptr_size != word.ptr_size)
+ return InferiorSizedWord(0, ptr_size);
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two & word.thirty_two, 4);
+ return InferiorSizedWord(sixty_four & word.sixty_four, 8);
+ }
+
+ InferiorSizedWord operator&(int x) const {
+ if (ptr_size == 4)
+ return InferiorSizedWord(thirty_two & x, 4);
+ return InferiorSizedWord(sixty_four & x, 8);
+ }
+
+ size_t GetBitSize() const { return ptr_size << 3; }
+
+ size_t GetByteSize() const { return ptr_size; }
+
+ uint64_t GetValue() const {
+ if (ptr_size == 4)
+ return (uint64_t)thirty_two;
+ return sixty_four;
+ }
+
+ InferiorSizedWord SignExtend() const {
+ if (ptr_size == 4)
+ return InferiorSizedWord((int32_t)thirty_two, 4);
+ return InferiorSizedWord((int64_t)sixty_four, 8);
+ }
+
+ uint8_t *CopyToBuffer(uint8_t *buffer) const {
+ if (ptr_size == 4) {
+ memcpy(buffer, &thirty_two, 4);
+ return buffer + 4;
+ } else {
+ memcpy(buffer, &sixty_four, 8);
+ return buffer + 8;
+ }
+ }
+
+ DataExtractor
+ GetAsData(lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const {
+ if (ptr_size == 4)
+ return DataExtractor(&thirty_two, 4, byte_order, 4);
+ else
+ return DataExtractor(&sixty_four, 8, byte_order, 8);
+ }
+
+private:
+ InferiorSizedWord(uint64_t val, size_t psz) : ptr_size(psz) {
+ if (ptr_size == 4)
+ thirty_two = (uint32_t)val;
+ else
+ sixty_four = val;
+ }
+
+ size_t ptr_size;
+ union {
+ uint32_t thirty_two;
+ uint64_t sixty_four;
+ };
+};
+} // namespace formatters
} // namespace lldb_private
-#endif // lldb_FormattersHelpers_h_
+#endif // lldb_FormattersHelpers_h_
Modified: lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/LanguageCategory.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- LanguageCategory.h----------------------------------------*- C++ -*-===//
+//===-- LanguageCategory.h----------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,85 +16,65 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormatCache.h"
#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/lldb-public.h"
#include <memory>
namespace lldb_private {
-class LanguageCategory
-{
+class LanguageCategory {
public:
- typedef std::unique_ptr<LanguageCategory> UniquePointer;
-
- LanguageCategory (lldb::LanguageType lang_type);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::TypeFormatImplSP& format_sp);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::TypeSummaryImplSP& format_sp);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::SyntheticChildrenSP& format_sp);
-
- bool
- Get (FormattersMatchData& match_data,
- lldb::TypeValidatorImplSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::TypeFormatImplSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::TypeSummaryImplSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::SyntheticChildrenSP& format_sp);
-
- bool
- GetHardcoded (FormatManager& fmt_mgr,
- FormattersMatchData& match_data,
- lldb::TypeValidatorImplSP& format_sp);
-
- lldb::TypeCategoryImplSP
- GetCategory () const;
-
- FormatCache&
- GetFormatCache ();
-
- void
- Enable ();
-
- void
- Disable ();
-
- bool
- IsEnabled ();
-
+ typedef std::unique_ptr<LanguageCategory> UniquePointer;
+
+ LanguageCategory(lldb::LanguageType lang_type);
+
+ bool Get(FormattersMatchData &match_data, lldb::TypeFormatImplSP &format_sp);
+
+ bool Get(FormattersMatchData &match_data, lldb::TypeSummaryImplSP &format_sp);
+
+ bool Get(FormattersMatchData &match_data,
+ lldb::SyntheticChildrenSP &format_sp);
+
+ bool Get(FormattersMatchData &match_data,
+ lldb::TypeValidatorImplSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::TypeFormatImplSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::TypeSummaryImplSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::SyntheticChildrenSP &format_sp);
+
+ bool GetHardcoded(FormatManager &fmt_mgr, FormattersMatchData &match_data,
+ lldb::TypeValidatorImplSP &format_sp);
+
+ lldb::TypeCategoryImplSP GetCategory() const;
+
+ FormatCache &GetFormatCache();
+
+ void Enable();
+
+ void Disable();
+
+ bool IsEnabled();
+
private:
- lldb::TypeCategoryImplSP m_category_sp;
-
- HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
- HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
- HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
- HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
-
- lldb_private::FormatCache m_format_cache;
-
- bool m_enabled;
+ lldb::TypeCategoryImplSP m_category_sp;
+
+ HardcodedFormatters::HardcodedFormatFinder m_hardcoded_formats;
+ HardcodedFormatters::HardcodedSummaryFinder m_hardcoded_summaries;
+ HardcodedFormatters::HardcodedSyntheticFinder m_hardcoded_synthetics;
+ HardcodedFormatters::HardcodedValidatorFinder m_hardcoded_validators;
+
+ lldb_private::FormatCache m_format_cache;
+
+ bool m_enabled;
};
-
+
} // namespace lldb_private
#endif // lldb_LanguageCategory_h_
Modified: lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/StringPrinter.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/StringPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/StringPrinter.h Tue Sep 6 15:57:50 2016
@@ -22,508 +22,327 @@
#include "lldb/Core/DataExtractor.h"
namespace lldb_private {
- namespace formatters
+namespace formatters {
+class StringPrinter {
+public:
+ enum class StringElementType { ASCII, UTF8, UTF16, UTF32 };
+
+ enum class GetPrintableElementType { ASCII, UTF8 };
+
+ class ReadStringAndDumpToStreamOptions {
+ public:
+ ReadStringAndDumpToStreamOptions()
+ : m_location(0), m_process_sp(), m_stream(nullptr), m_prefix_token(),
+ m_suffix_token(), m_quote('"'), m_source_size(0),
+ m_needs_zero_termination(true), m_escape_non_printables(true),
+ m_ignore_max_length(false), m_zero_is_terminator(true),
+ m_language_type(lldb::eLanguageTypeUnknown) {}
+
+ ReadStringAndDumpToStreamOptions(ValueObject &valobj);
+
+ ReadStringAndDumpToStreamOptions &SetLocation(uint64_t l) {
+ m_location = l;
+ return *this;
+ }
+
+ uint64_t GetLocation() const { return m_location; }
+
+ ReadStringAndDumpToStreamOptions &SetProcessSP(lldb::ProcessSP p) {
+ m_process_sp = p;
+ return *this;
+ }
+
+ lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
+
+ ReadStringAndDumpToStreamOptions &SetStream(Stream *s) {
+ m_stream = s;
+ return *this;
+ }
+
+ Stream *GetStream() const { return m_stream; }
+
+ ReadStringAndDumpToStreamOptions &SetPrefixToken(const std::string &p) {
+ m_prefix_token = p;
+ return *this;
+ }
+
+ ReadStringAndDumpToStreamOptions &SetPrefixToken(std::nullptr_t) {
+ m_prefix_token.clear();
+ return *this;
+ }
+
+ const char *GetPrefixToken() const { return m_prefix_token.c_str(); }
+
+ ReadStringAndDumpToStreamOptions &SetSuffixToken(const std::string &p) {
+ m_suffix_token = p;
+ return *this;
+ }
+
+ ReadStringAndDumpToStreamOptions &SetSuffixToken(std::nullptr_t) {
+ m_suffix_token.clear();
+ return *this;
+ }
+
+ const char *GetSuffixToken() const { return m_suffix_token.c_str(); }
+
+ ReadStringAndDumpToStreamOptions &SetQuote(char q) {
+ m_quote = q;
+ return *this;
+ }
+
+ char GetQuote() const { return m_quote; }
+
+ ReadStringAndDumpToStreamOptions &SetSourceSize(uint32_t s) {
+ m_source_size = s;
+ return *this;
+ }
+
+ uint32_t GetSourceSize() const { return m_source_size; }
+
+ ReadStringAndDumpToStreamOptions &SetNeedsZeroTermination(bool z) {
+ m_needs_zero_termination = z;
+ return *this;
+ }
+
+ bool GetNeedsZeroTermination() const { return m_needs_zero_termination; }
+
+ ReadStringAndDumpToStreamOptions &SetBinaryZeroIsTerminator(bool e) {
+ m_zero_is_terminator = e;
+ return *this;
+ }
+
+ bool GetBinaryZeroIsTerminator() const { return m_zero_is_terminator; }
+
+ ReadStringAndDumpToStreamOptions &SetEscapeNonPrintables(bool e) {
+ m_escape_non_printables = e;
+ return *this;
+ }
+
+ bool GetEscapeNonPrintables() const { return m_escape_non_printables; }
+
+ ReadStringAndDumpToStreamOptions &SetIgnoreMaxLength(bool e) {
+ m_ignore_max_length = e;
+ return *this;
+ }
+
+ bool GetIgnoreMaxLength() const { return m_ignore_max_length; }
+
+ ReadStringAndDumpToStreamOptions &SetLanguage(lldb::LanguageType l) {
+ m_language_type = l;
+ return *this;
+ }
+
+ lldb::LanguageType GetLanguage() const
+
{
- class StringPrinter
- {
- public:
- enum class StringElementType
- {
- ASCII,
- UTF8,
- UTF16,
- UTF32
- };
-
- enum class GetPrintableElementType
- {
- ASCII,
- UTF8
- };
-
- class ReadStringAndDumpToStreamOptions
- {
- public:
- ReadStringAndDumpToStreamOptions () :
- m_location(0),
- m_process_sp(),
- m_stream(nullptr),
- m_prefix_token(),
- m_suffix_token(),
- m_quote('"'),
- m_source_size(0),
- m_needs_zero_termination(true),
- m_escape_non_printables(true),
- m_ignore_max_length(false),
- m_zero_is_terminator(true),
- m_language_type(lldb::eLanguageTypeUnknown)
- {
- }
-
- ReadStringAndDumpToStreamOptions (ValueObject& valobj);
-
- ReadStringAndDumpToStreamOptions&
- SetLocation (uint64_t l)
- {
- m_location = l;
- return *this;
- }
-
- uint64_t
- GetLocation () const
- {
- return m_location;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetProcessSP (lldb::ProcessSP p)
- {
- m_process_sp = p;
- return *this;
- }
-
- lldb::ProcessSP
- GetProcessSP () const
- {
- return m_process_sp;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetStream (Stream* s)
- {
- m_stream = s;
- return *this;
- }
-
- Stream*
- GetStream () const
- {
- return m_stream;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetPrefixToken (const std::string& p)
- {
- m_prefix_token = p;
- return *this;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetPrefixToken (std::nullptr_t)
- {
- m_prefix_token.clear();
- return *this;
- }
-
- const char*
- GetPrefixToken () const
- {
- return m_prefix_token.c_str();
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSuffixToken (const std::string& p)
- {
- m_suffix_token = p;
- return *this;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSuffixToken (std::nullptr_t)
- {
- m_suffix_token.clear();
- return *this;
- }
-
- const char*
- GetSuffixToken () const
- {
- return m_suffix_token.c_str();
- }
-
- ReadStringAndDumpToStreamOptions&
- SetQuote (char q)
- {
- m_quote = q;
- return *this;
- }
-
- char
- GetQuote () const
- {
- return m_quote;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetSourceSize (uint32_t s)
- {
- m_source_size = s;
- return *this;
- }
-
- uint32_t
- GetSourceSize () const
- {
- return m_source_size;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetNeedsZeroTermination (bool z)
- {
- m_needs_zero_termination = z;
- return *this;
- }
-
- bool
- GetNeedsZeroTermination () const
- {
- return m_needs_zero_termination;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetBinaryZeroIsTerminator (bool e)
- {
- m_zero_is_terminator = e;
- return *this;
- }
-
- bool
- GetBinaryZeroIsTerminator () const
- {
- return m_zero_is_terminator;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetEscapeNonPrintables (bool e)
- {
- m_escape_non_printables = e;
- return *this;
- }
-
- bool
- GetEscapeNonPrintables () const
- {
- return m_escape_non_printables;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetIgnoreMaxLength (bool e)
- {
- m_ignore_max_length = e;
- return *this;
- }
-
- bool
- GetIgnoreMaxLength () const
- {
- return m_ignore_max_length;
- }
-
- ReadStringAndDumpToStreamOptions&
- SetLanguage (lldb::LanguageType l)
- {
- m_language_type = l;
- return *this;
- }
-
- lldb::LanguageType
- GetLanguage () const
-
- {
- return m_language_type;
- }
-
- private:
- uint64_t m_location;
- lldb::ProcessSP m_process_sp;
- Stream* m_stream;
- std::string m_prefix_token;
- std::string m_suffix_token;
- char m_quote;
- uint32_t m_source_size;
- bool m_needs_zero_termination;
- bool m_escape_non_printables;
- bool m_ignore_max_length;
- bool m_zero_is_terminator;
- lldb::LanguageType m_language_type;
- };
-
- class ReadBufferAndDumpToStreamOptions
- {
- public:
- ReadBufferAndDumpToStreamOptions () :
- m_data(),
- m_stream(nullptr),
- m_prefix_token(),
- m_suffix_token(),
- m_quote('"'),
- m_source_size(0),
- m_escape_non_printables(true),
- m_zero_is_terminator(true),
- m_is_truncated(false),
- m_language_type(lldb::eLanguageTypeUnknown)
- {
- }
-
- ReadBufferAndDumpToStreamOptions (ValueObject& valobj);
-
- ReadBufferAndDumpToStreamOptions (const ReadStringAndDumpToStreamOptions& options);
-
- ReadBufferAndDumpToStreamOptions&
- SetData (DataExtractor d)
- {
- m_data = d;
- return *this;
- }
-
- lldb_private::DataExtractor
- GetData () const
- {
- return m_data;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetStream (Stream* s)
- {
- m_stream = s;
- return *this;
- }
-
- Stream*
- GetStream () const
- {
- return m_stream;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetPrefixToken (const std::string& p)
- {
- m_prefix_token = p;
- return *this;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetPrefixToken (std::nullptr_t)
- {
- m_prefix_token.clear();
- return *this;
- }
-
- const char*
- GetPrefixToken () const
- {
- return m_prefix_token.c_str();
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSuffixToken (const std::string& p)
- {
- m_suffix_token = p;
- return *this;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSuffixToken (std::nullptr_t)
- {
- m_suffix_token.clear();
- return *this;
- }
-
- const char*
- GetSuffixToken () const
- {
- return m_suffix_token.c_str();
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetQuote (char q)
- {
- m_quote = q;
- return *this;
- }
-
- char
- GetQuote () const
- {
- return m_quote;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetSourceSize (uint32_t s)
- {
- m_source_size = s;
- return *this;
- }
-
- uint32_t
- GetSourceSize () const
- {
- return m_source_size;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetEscapeNonPrintables (bool e)
- {
- m_escape_non_printables = e;
- return *this;
- }
-
- bool
- GetEscapeNonPrintables () const
- {
- return m_escape_non_printables;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetBinaryZeroIsTerminator (bool e)
- {
- m_zero_is_terminator = e;
- return *this;
- }
-
- bool
- GetBinaryZeroIsTerminator () const
- {
- return m_zero_is_terminator;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetIsTruncated (bool t)
- {
- m_is_truncated = t;
- return *this;
- }
-
- bool
- GetIsTruncated () const
- {
- return m_is_truncated;
- }
-
- ReadBufferAndDumpToStreamOptions&
- SetLanguage (lldb::LanguageType l)
- {
- m_language_type = l;
- return *this;
- }
-
- lldb::LanguageType
- GetLanguage () const
-
- {
- return m_language_type;
- }
-
- private:
- DataExtractor m_data;
- Stream* m_stream;
- std::string m_prefix_token;
- std::string m_suffix_token;
- char m_quote;
- uint32_t m_source_size;
- bool m_escape_non_printables;
- bool m_zero_is_terminator;
- bool m_is_truncated;
- lldb::LanguageType m_language_type;
- };
-
- // I can't use a std::unique_ptr for this because the Deleter is a template argument there
- // and I want the same type to represent both pointers I want to free and pointers I don't need
- // to free - which is what this class essentially is
- // It's very specialized to the needs of this file, and not suggested for general use
- template <typename T = uint8_t, typename U = char, typename S = size_t>
- struct StringPrinterBufferPointer
- {
- public:
- typedef std::function<void(const T*)> Deleter;
-
- StringPrinterBufferPointer (std::nullptr_t ptr) :
- m_data(nullptr),
- m_size(0),
- m_deleter()
- {}
-
- StringPrinterBufferPointer(const T* bytes, S size, Deleter deleter = nullptr) :
- m_data(bytes),
- m_size(size),
- m_deleter(deleter)
- {}
-
- StringPrinterBufferPointer(const U* bytes, S size, Deleter deleter = nullptr) :
- m_data(reinterpret_cast<const T*>(bytes)),
- m_size(size),
- m_deleter(deleter)
- {}
-
- StringPrinterBufferPointer(StringPrinterBufferPointer&& rhs) :
- m_data(rhs.m_data),
- m_size(rhs.m_size),
- m_deleter(rhs.m_deleter)
- {
- rhs.m_data = nullptr;
- }
-
- StringPrinterBufferPointer(const StringPrinterBufferPointer& rhs) :
- m_data(rhs.m_data),
- m_size(rhs.m_size),
- m_deleter(rhs.m_deleter)
- {
- rhs.m_data = nullptr; // this is why m_data has to be mutable
- }
-
- ~StringPrinterBufferPointer()
- {
- if (m_data && m_deleter)
- m_deleter(m_data);
- m_data = nullptr;
- }
-
- const T*
- GetBytes () const
- {
- return m_data;
- }
-
- const S
- GetSize () const
- {
- return m_size;
- }
-
- StringPrinterBufferPointer&
- operator = (const StringPrinterBufferPointer& rhs)
- {
- if (m_data && m_deleter)
- m_deleter(m_data);
- m_data = rhs.m_data;
- m_size = rhs.m_size;
- m_deleter = rhs.m_deleter;
- rhs.m_data = nullptr;
- return *this;
- }
-
- private:
- mutable const T* m_data;
- size_t m_size;
- Deleter m_deleter;
- };
-
- typedef std::function<StringPrinter::StringPrinterBufferPointer<uint8_t,char,size_t>(uint8_t*, uint8_t*, uint8_t*&)> EscapingHelper;
- typedef std::function<EscapingHelper(GetPrintableElementType)> EscapingHelperGenerator;
-
- static EscapingHelper
- GetDefaultEscapingHelper (GetPrintableElementType elem_type);
-
- template <StringElementType element_type>
- static bool
- ReadStringAndDumpToStream (const ReadStringAndDumpToStreamOptions& options);
-
- template <StringElementType element_type>
- static bool
- ReadBufferAndDumpToStream (const ReadBufferAndDumpToStreamOptions& options);
- };
-
- } // namespace formatters
+ return m_language_type;
+ }
+
+ private:
+ uint64_t m_location;
+ lldb::ProcessSP m_process_sp;
+ Stream *m_stream;
+ std::string m_prefix_token;
+ std::string m_suffix_token;
+ char m_quote;
+ uint32_t m_source_size;
+ bool m_needs_zero_termination;
+ bool m_escape_non_printables;
+ bool m_ignore_max_length;
+ bool m_zero_is_terminator;
+ lldb::LanguageType m_language_type;
+ };
+
+ class ReadBufferAndDumpToStreamOptions {
+ public:
+ ReadBufferAndDumpToStreamOptions()
+ : m_data(), m_stream(nullptr), m_prefix_token(), m_suffix_token(),
+ m_quote('"'), m_source_size(0), m_escape_non_printables(true),
+ m_zero_is_terminator(true), m_is_truncated(false),
+ m_language_type(lldb::eLanguageTypeUnknown) {}
+
+ ReadBufferAndDumpToStreamOptions(ValueObject &valobj);
+
+ ReadBufferAndDumpToStreamOptions(
+ const ReadStringAndDumpToStreamOptions &options);
+
+ ReadBufferAndDumpToStreamOptions &SetData(DataExtractor d) {
+ m_data = d;
+ return *this;
+ }
+
+ lldb_private::DataExtractor GetData() const { return m_data; }
+
+ ReadBufferAndDumpToStreamOptions &SetStream(Stream *s) {
+ m_stream = s;
+ return *this;
+ }
+
+ Stream *GetStream() const { return m_stream; }
+
+ ReadBufferAndDumpToStreamOptions &SetPrefixToken(const std::string &p) {
+ m_prefix_token = p;
+ return *this;
+ }
+
+ ReadBufferAndDumpToStreamOptions &SetPrefixToken(std::nullptr_t) {
+ m_prefix_token.clear();
+ return *this;
+ }
+
+ const char *GetPrefixToken() const { return m_prefix_token.c_str(); }
+
+ ReadBufferAndDumpToStreamOptions &SetSuffixToken(const std::string &p) {
+ m_suffix_token = p;
+ return *this;
+ }
+
+ ReadBufferAndDumpToStreamOptions &SetSuffixToken(std::nullptr_t) {
+ m_suffix_token.clear();
+ return *this;
+ }
+
+ const char *GetSuffixToken() const { return m_suffix_token.c_str(); }
+
+ ReadBufferAndDumpToStreamOptions &SetQuote(char q) {
+ m_quote = q;
+ return *this;
+ }
+
+ char GetQuote() const { return m_quote; }
+
+ ReadBufferAndDumpToStreamOptions &SetSourceSize(uint32_t s) {
+ m_source_size = s;
+ return *this;
+ }
+
+ uint32_t GetSourceSize() const { return m_source_size; }
+
+ ReadBufferAndDumpToStreamOptions &SetEscapeNonPrintables(bool e) {
+ m_escape_non_printables = e;
+ return *this;
+ }
+
+ bool GetEscapeNonPrintables() const { return m_escape_non_printables; }
+
+ ReadBufferAndDumpToStreamOptions &SetBinaryZeroIsTerminator(bool e) {
+ m_zero_is_terminator = e;
+ return *this;
+ }
+
+ bool GetBinaryZeroIsTerminator() const { return m_zero_is_terminator; }
+
+ ReadBufferAndDumpToStreamOptions &SetIsTruncated(bool t) {
+ m_is_truncated = t;
+ return *this;
+ }
+
+ bool GetIsTruncated() const { return m_is_truncated; }
+
+ ReadBufferAndDumpToStreamOptions &SetLanguage(lldb::LanguageType l) {
+ m_language_type = l;
+ return *this;
+ }
+
+ lldb::LanguageType GetLanguage() const
+
+ {
+ return m_language_type;
+ }
+
+ private:
+ DataExtractor m_data;
+ Stream *m_stream;
+ std::string m_prefix_token;
+ std::string m_suffix_token;
+ char m_quote;
+ uint32_t m_source_size;
+ bool m_escape_non_printables;
+ bool m_zero_is_terminator;
+ bool m_is_truncated;
+ lldb::LanguageType m_language_type;
+ };
+
+ // I can't use a std::unique_ptr for this because the Deleter is a template
+ // argument there
+ // and I want the same type to represent both pointers I want to free and
+ // pointers I don't need
+ // to free - which is what this class essentially is
+ // It's very specialized to the needs of this file, and not suggested for
+ // general use
+ template <typename T = uint8_t, typename U = char, typename S = size_t>
+ struct StringPrinterBufferPointer {
+ public:
+ typedef std::function<void(const T *)> Deleter;
+
+ StringPrinterBufferPointer(std::nullptr_t ptr)
+ : m_data(nullptr), m_size(0), m_deleter() {}
+
+ StringPrinterBufferPointer(const T *bytes, S size,
+ Deleter deleter = nullptr)
+ : m_data(bytes), m_size(size), m_deleter(deleter) {}
+
+ StringPrinterBufferPointer(const U *bytes, S size,
+ Deleter deleter = nullptr)
+ : m_data(reinterpret_cast<const T *>(bytes)), m_size(size),
+ m_deleter(deleter) {}
+
+ StringPrinterBufferPointer(StringPrinterBufferPointer &&rhs)
+ : m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) {
+ rhs.m_data = nullptr;
+ }
+
+ StringPrinterBufferPointer(const StringPrinterBufferPointer &rhs)
+ : m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) {
+ rhs.m_data = nullptr; // this is why m_data has to be mutable
+ }
+
+ ~StringPrinterBufferPointer() {
+ if (m_data && m_deleter)
+ m_deleter(m_data);
+ m_data = nullptr;
+ }
+
+ const T *GetBytes() const { return m_data; }
+
+ const S GetSize() const { return m_size; }
+
+ StringPrinterBufferPointer &
+ operator=(const StringPrinterBufferPointer &rhs) {
+ if (m_data && m_deleter)
+ m_deleter(m_data);
+ m_data = rhs.m_data;
+ m_size = rhs.m_size;
+ m_deleter = rhs.m_deleter;
+ rhs.m_data = nullptr;
+ return *this;
+ }
+
+ private:
+ mutable const T *m_data;
+ size_t m_size;
+ Deleter m_deleter;
+ };
+
+ typedef std::function<StringPrinter::StringPrinterBufferPointer<
+ uint8_t, char, size_t>(uint8_t *, uint8_t *, uint8_t *&)>
+ EscapingHelper;
+ typedef std::function<EscapingHelper(GetPrintableElementType)>
+ EscapingHelperGenerator;
+
+ static EscapingHelper
+ GetDefaultEscapingHelper(GetPrintableElementType elem_type);
+
+ template <StringElementType element_type>
+ static bool
+ ReadStringAndDumpToStream(const ReadStringAndDumpToStreamOptions &options);
+
+ template <StringElementType element_type>
+ static bool
+ ReadBufferAndDumpToStream(const ReadBufferAndDumpToStreamOptions &options);
+};
+
+} // namespace formatters
} // namespace lldb_private
#endif // liblldb_StringPrinter_h_
Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Tue Sep 6 15:57:50 2016
@@ -20,561 +20,433 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormattersContainer.h"
namespace lldb_private {
-
- template <typename FormatterImpl>
- class FormatterContainerPair
- {
- public:
- typedef FormattersContainer<ConstString, FormatterImpl> ExactMatchContainer;
- typedef FormattersContainer<lldb::RegularExpressionSP, FormatterImpl> RegexMatchContainer;
-
- typedef typename ExactMatchContainer::MapType ExactMatchMap;
- typedef typename RegexMatchContainer::MapType RegexMatchMap;
-
- typedef typename ExactMatchContainer::MapValueType MapValueType;
-
- typedef typename ExactMatchContainer::SharedPointer ExactMatchContainerSP;
- typedef typename RegexMatchContainer::SharedPointer RegexMatchContainerSP;
-
- typedef typename ExactMatchContainer::ForEachCallback ExactMatchForEachCallback;
- typedef typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
-
- FormatterContainerPair (const char* exact_name,
- const char* regex_name,
- IFormatChangeListener* clist) :
- m_exact_sp(new ExactMatchContainer(std::string(exact_name),clist)),
- m_regex_sp(new RegexMatchContainer(std::string(regex_name),clist))
- {
- }
-
- ~FormatterContainerPair () = default;
-
- ExactMatchContainerSP
- GetExactMatch () const
- {
- return m_exact_sp;
- }
-
- RegexMatchContainerSP
- GetRegexMatch () const
- {
- return m_regex_sp;
- }
-
- uint32_t
- GetCount ()
- {
- return GetExactMatch()->GetCount() + GetRegexMatch()->GetCount();
- }
-
- private:
- ExactMatchContainerSP m_exact_sp;
- RegexMatchContainerSP m_regex_sp;
- };
-
- class TypeCategoryImpl
- {
- private:
- typedef FormatterContainerPair<TypeFormatImpl> FormatContainer;
- typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
- typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
- typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
-
+
+template <typename FormatterImpl> class FormatterContainerPair {
+public:
+ typedef FormattersContainer<ConstString, FormatterImpl> ExactMatchContainer;
+ typedef FormattersContainer<lldb::RegularExpressionSP, FormatterImpl>
+ RegexMatchContainer;
+
+ typedef typename ExactMatchContainer::MapType ExactMatchMap;
+ typedef typename RegexMatchContainer::MapType RegexMatchMap;
+
+ typedef typename ExactMatchContainer::MapValueType MapValueType;
+
+ typedef typename ExactMatchContainer::SharedPointer ExactMatchContainerSP;
+ typedef typename RegexMatchContainer::SharedPointer RegexMatchContainerSP;
+
+ typedef
+ typename ExactMatchContainer::ForEachCallback ExactMatchForEachCallback;
+ typedef
+ typename RegexMatchContainer::ForEachCallback RegexMatchForEachCallback;
+
+ FormatterContainerPair(const char *exact_name, const char *regex_name,
+ IFormatChangeListener *clist)
+ : m_exact_sp(new ExactMatchContainer(std::string(exact_name), clist)),
+ m_regex_sp(new RegexMatchContainer(std::string(regex_name), clist)) {}
+
+ ~FormatterContainerPair() = default;
+
+ ExactMatchContainerSP GetExactMatch() const { return m_exact_sp; }
+
+ RegexMatchContainerSP GetRegexMatch() const { return m_regex_sp; }
+
+ uint32_t GetCount() {
+ return GetExactMatch()->GetCount() + GetRegexMatch()->GetCount();
+ }
+
+private:
+ ExactMatchContainerSP m_exact_sp;
+ RegexMatchContainerSP m_regex_sp;
+};
+
+class TypeCategoryImpl {
+private:
+ typedef FormatterContainerPair<TypeFormatImpl> FormatContainer;
+ typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
+ typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
+ typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
+
#ifndef LLDB_DISABLE_PYTHON
- typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
+ typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
#endif // LLDB_DISABLE_PYTHON
- public:
- typedef uint16_t FormatCategoryItems;
- static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
-
- typedef FormatContainer::ExactMatchContainerSP FormatContainerSP;
- typedef FormatContainer::RegexMatchContainerSP RegexFormatContainerSP;
-
- typedef SummaryContainer::ExactMatchContainerSP SummaryContainerSP;
- typedef SummaryContainer::RegexMatchContainerSP RegexSummaryContainerSP;
+public:
+ typedef uint16_t FormatCategoryItems;
+ static const uint16_t ALL_ITEM_TYPES = UINT16_MAX;
+
+ typedef FormatContainer::ExactMatchContainerSP FormatContainerSP;
+ typedef FormatContainer::RegexMatchContainerSP RegexFormatContainerSP;
- typedef FilterContainer::ExactMatchContainerSP FilterContainerSP;
- typedef FilterContainer::RegexMatchContainerSP RegexFilterContainerSP;
+ typedef SummaryContainer::ExactMatchContainerSP SummaryContainerSP;
+ typedef SummaryContainer::RegexMatchContainerSP RegexSummaryContainerSP;
+
+ typedef FilterContainer::ExactMatchContainerSP FilterContainerSP;
+ typedef FilterContainer::RegexMatchContainerSP RegexFilterContainerSP;
#ifndef LLDB_DISABLE_PYTHON
- typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
- typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
+ typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
+ typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
#endif // LLDB_DISABLE_PYTHON
-
- typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
- typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
-
- template <typename T>
- class ForEachCallbacks
- {
- public:
- ForEachCallbacks () = default;
- ~ForEachCallbacks () = default;
-
- template<typename U = TypeFormatImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (FormatContainer::ExactMatchForEachCallback callback)
- {
- m_format_exact = callback;
- return *this;
- }
- template<typename U = TypeFormatImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (FormatContainer::RegexMatchForEachCallback callback)
- {
- m_format_regex = callback;
- return *this;
- }
-
- template<typename U = TypeSummaryImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (SummaryContainer::ExactMatchForEachCallback callback)
- {
- m_summary_exact = callback;
- return *this;
- }
- template<typename U = TypeSummaryImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (SummaryContainer::RegexMatchForEachCallback callback)
- {
- m_summary_regex = callback;
- return *this;
- }
-
- template<typename U = TypeFilterImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (FilterContainer::ExactMatchForEachCallback callback)
- {
- m_filter_exact = callback;
- return *this;
- }
- template<typename U = TypeFilterImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (FilterContainer::RegexMatchForEachCallback callback)
- {
- m_filter_regex = callback;
- return *this;
- }
+
+ typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
+ typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
+
+ template <typename T> class ForEachCallbacks {
+ public:
+ ForEachCallbacks() = default;
+ ~ForEachCallbacks() = default;
+
+ template <typename U = TypeFormatImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(FormatContainer::ExactMatchForEachCallback callback) {
+ m_format_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeFormatImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(FormatContainer::RegexMatchForEachCallback callback) {
+ m_format_regex = callback;
+ return *this;
+ }
+
+ template <typename U = TypeSummaryImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(SummaryContainer::ExactMatchForEachCallback callback) {
+ m_summary_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeSummaryImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(SummaryContainer::RegexMatchForEachCallback callback) {
+ m_summary_regex = callback;
+ return *this;
+ }
+
+ template <typename U = TypeFilterImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(FilterContainer::ExactMatchForEachCallback callback) {
+ m_filter_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeFilterImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(FilterContainer::RegexMatchForEachCallback callback) {
+ m_filter_regex = callback;
+ return *this;
+ }
#ifndef LLDB_DISABLE_PYTHON
- template<typename U = SyntheticChildren>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (SynthContainer::ExactMatchForEachCallback callback)
- {
- m_synth_exact = callback;
- return *this;
- }
- template<typename U = SyntheticChildren>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (SynthContainer::RegexMatchForEachCallback callback)
- {
- m_synth_regex = callback;
- return *this;
- }
+ template <typename U = SyntheticChildren>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(SynthContainer::ExactMatchForEachCallback callback) {
+ m_synth_exact = callback;
+ return *this;
+ }
+ template <typename U = SyntheticChildren>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(SynthContainer::RegexMatchForEachCallback callback) {
+ m_synth_regex = callback;
+ return *this;
+ }
#endif // LLDB_DISABLE_PYTHON
- template<typename U = TypeValidatorImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetExact (ValidatorContainer::ExactMatchForEachCallback callback)
- {
- m_validator_exact = callback;
- return *this;
- }
- template<typename U = TypeValidatorImpl>
- typename std::enable_if<std::is_same<U,T>::value, ForEachCallbacks&>::type
- SetWithRegex (ValidatorContainer::RegexMatchForEachCallback callback)
- {
- m_validator_regex = callback;
- return *this;
- }
-
- FormatContainer::ExactMatchForEachCallback
- GetFormatExactCallback () const
- {
- return m_format_exact;
- }
- FormatContainer::RegexMatchForEachCallback
- GetFormatRegexCallback () const
- {
- return m_format_regex;
- }
-
- SummaryContainer::ExactMatchForEachCallback
- GetSummaryExactCallback () const
- {
- return m_summary_exact;
- }
- SummaryContainer::RegexMatchForEachCallback
- GetSummaryRegexCallback () const
- {
- return m_summary_regex;
- }
-
- FilterContainer::ExactMatchForEachCallback
- GetFilterExactCallback () const
- {
- return m_filter_exact;
- }
- FilterContainer::RegexMatchForEachCallback
- GetFilterRegexCallback () const
- {
- return m_filter_regex;
- }
+ template <typename U = TypeValidatorImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetExact(ValidatorContainer::ExactMatchForEachCallback callback) {
+ m_validator_exact = callback;
+ return *this;
+ }
+ template <typename U = TypeValidatorImpl>
+ typename std::enable_if<std::is_same<U, T>::value, ForEachCallbacks &>::type
+ SetWithRegex(ValidatorContainer::RegexMatchForEachCallback callback) {
+ m_validator_regex = callback;
+ return *this;
+ }
+
+ FormatContainer::ExactMatchForEachCallback GetFormatExactCallback() const {
+ return m_format_exact;
+ }
+ FormatContainer::RegexMatchForEachCallback GetFormatRegexCallback() const {
+ return m_format_regex;
+ }
+
+ SummaryContainer::ExactMatchForEachCallback
+ GetSummaryExactCallback() const {
+ return m_summary_exact;
+ }
+ SummaryContainer::RegexMatchForEachCallback
+ GetSummaryRegexCallback() const {
+ return m_summary_regex;
+ }
+
+ FilterContainer::ExactMatchForEachCallback GetFilterExactCallback() const {
+ return m_filter_exact;
+ }
+ FilterContainer::RegexMatchForEachCallback GetFilterRegexCallback() const {
+ return m_filter_regex;
+ }
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer::ExactMatchForEachCallback
- GetSynthExactCallback () const
- {
- return m_synth_exact;
- }
- SynthContainer::RegexMatchForEachCallback
- GetSynthRegexCallback () const
- {
- return m_synth_regex;
- }
+ SynthContainer::ExactMatchForEachCallback GetSynthExactCallback() const {
+ return m_synth_exact;
+ }
+ SynthContainer::RegexMatchForEachCallback GetSynthRegexCallback() const {
+ return m_synth_regex;
+ }
#endif // LLDB_DISABLE_PYTHON
- ValidatorContainer::ExactMatchForEachCallback
- GetValidatorExactCallback () const
- {
- return m_validator_exact;
- }
- ValidatorContainer::RegexMatchForEachCallback
- GetValidatorRegexCallback () const
- {
- return m_validator_regex;
- }
-
- private:
- FormatContainer::ExactMatchForEachCallback m_format_exact;
- FormatContainer::RegexMatchForEachCallback m_format_regex;
-
- SummaryContainer::ExactMatchForEachCallback m_summary_exact;
- SummaryContainer::RegexMatchForEachCallback m_summary_regex;
-
- FilterContainer::ExactMatchForEachCallback m_filter_exact;
- FilterContainer::RegexMatchForEachCallback m_filter_regex;
+ ValidatorContainer::ExactMatchForEachCallback
+ GetValidatorExactCallback() const {
+ return m_validator_exact;
+ }
+ ValidatorContainer::RegexMatchForEachCallback
+ GetValidatorRegexCallback() const {
+ return m_validator_regex;
+ }
+
+ private:
+ FormatContainer::ExactMatchForEachCallback m_format_exact;
+ FormatContainer::RegexMatchForEachCallback m_format_regex;
+
+ SummaryContainer::ExactMatchForEachCallback m_summary_exact;
+ SummaryContainer::RegexMatchForEachCallback m_summary_regex;
+
+ FilterContainer::ExactMatchForEachCallback m_filter_exact;
+ FilterContainer::RegexMatchForEachCallback m_filter_regex;
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer::ExactMatchForEachCallback m_synth_exact;
- SynthContainer::RegexMatchForEachCallback m_synth_regex;
+ SynthContainer::ExactMatchForEachCallback m_synth_exact;
+ SynthContainer::RegexMatchForEachCallback m_synth_regex;
#endif // LLDB_DISABLE_PYTHON
- ValidatorContainer::ExactMatchForEachCallback m_validator_exact;
- ValidatorContainer::RegexMatchForEachCallback m_validator_regex;
- };
-
- TypeCategoryImpl (IFormatChangeListener* clist,
- ConstString name,
- std::initializer_list<lldb::LanguageType> langs = {});
-
- template <typename T>
- void
- ForEach (const ForEachCallbacks<T> &foreach)
- {
- GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback());
- GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback());
-
- GetTypeSummariesContainer()->ForEach(foreach.GetSummaryExactCallback());
- GetRegexTypeSummariesContainer()->ForEach(foreach.GetSummaryRegexCallback());
-
- GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback());
- GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback());
-
+ ValidatorContainer::ExactMatchForEachCallback m_validator_exact;
+ ValidatorContainer::RegexMatchForEachCallback m_validator_regex;
+ };
+
+ TypeCategoryImpl(IFormatChangeListener *clist, ConstString name,
+ std::initializer_list<lldb::LanguageType> langs = {});
+
+ template <typename T> void ForEach(const ForEachCallbacks<T> &foreach) {
+ GetTypeFormatsContainer()->ForEach(foreach.GetFormatExactCallback());
+ GetRegexTypeFormatsContainer()->ForEach(foreach.GetFormatRegexCallback());
+
+ GetTypeSummariesContainer()->ForEach(foreach.GetSummaryExactCallback());
+ GetRegexTypeSummariesContainer()->ForEach(
+ foreach.GetSummaryRegexCallback());
+
+ GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback());
+ GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback());
+
#ifndef LLDB_DISABLE_PYTHON
- GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
- GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
+ GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
+ GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
#endif // LLDB_DISABLE_PYTHON
-
- GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
- GetRegexTypeValidatorsContainer()->ForEach(foreach.GetValidatorRegexCallback());
- }
-
- FormatContainerSP
- GetTypeFormatsContainer ()
- {
- return m_format_cont.GetExactMatch();
- }
-
- RegexFormatContainerSP
- GetRegexTypeFormatsContainer ()
- {
- return m_format_cont.GetRegexMatch();
- }
-
- FormatContainer&
- GetFormatContainer ()
- {
- return m_format_cont;
- }
-
- SummaryContainerSP
- GetTypeSummariesContainer ()
- {
- return m_summary_cont.GetExactMatch();
- }
-
- RegexSummaryContainerSP
- GetRegexTypeSummariesContainer ()
- {
- return m_summary_cont.GetRegexMatch();
- }
-
- SummaryContainer&
- GetSummaryContainer ()
- {
- return m_summary_cont;
- }
-
- FilterContainerSP
- GetTypeFiltersContainer ()
- {
- return m_filter_cont.GetExactMatch();
- }
-
- RegexFilterContainerSP
- GetRegexTypeFiltersContainer ()
- {
- return m_filter_cont.GetRegexMatch();
- }
-
- FilterContainer&
- GetFilterContainer ()
- {
- return m_filter_cont;
- }
-
- FormatContainer::MapValueType
- GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- SummaryContainer::MapValueType
- GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- FilterContainer::MapValueType
- GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp);
-
+
+ GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
+ GetRegexTypeValidatorsContainer()->ForEach(
+ foreach.GetValidatorRegexCallback());
+ }
+
+ FormatContainerSP GetTypeFormatsContainer() {
+ return m_format_cont.GetExactMatch();
+ }
+
+ RegexFormatContainerSP GetRegexTypeFormatsContainer() {
+ return m_format_cont.GetRegexMatch();
+ }
+
+ FormatContainer &GetFormatContainer() { return m_format_cont; }
+
+ SummaryContainerSP GetTypeSummariesContainer() {
+ return m_summary_cont.GetExactMatch();
+ }
+
+ RegexSummaryContainerSP GetRegexTypeSummariesContainer() {
+ return m_summary_cont.GetRegexMatch();
+ }
+
+ SummaryContainer &GetSummaryContainer() { return m_summary_cont; }
+
+ FilterContainerSP GetTypeFiltersContainer() {
+ return m_filter_cont.GetExactMatch();
+ }
+
+ RegexFilterContainerSP GetRegexTypeFiltersContainer() {
+ return m_filter_cont.GetRegexMatch();
+ }
+
+ FilterContainer &GetFilterContainer() { return m_filter_cont; }
+
+ FormatContainer::MapValueType
+ GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ SummaryContainer::MapValueType
+ GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ FilterContainer::MapValueType
+ GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
+
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer::MapValueType
- GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp);
+ SynthContainer::MapValueType
+ GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
#endif
-
- ValidatorContainer::MapValueType
- GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFormatAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSummaryAtIndex (size_t index);
-
- FormatContainer::MapValueType
- GetFormatAtIndex (size_t index);
-
- SummaryContainer::MapValueType
- GetSummaryAtIndex (size_t index);
-
- FilterContainer::MapValueType
- GetFilterAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForFilterAtIndex (size_t index);
-
+
+ ValidatorContainer::MapValueType
+ GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForFormatAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForSummaryAtIndex(size_t index);
+
+ FormatContainer::MapValueType GetFormatAtIndex(size_t index);
+
+ SummaryContainer::MapValueType GetSummaryAtIndex(size_t index);
+
+ FilterContainer::MapValueType GetFilterAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForFilterAtIndex(size_t index);
+
#ifndef LLDB_DISABLE_PYTHON
- SynthContainerSP
- GetTypeSyntheticsContainer ()
- {
- return m_synth_cont.GetExactMatch();
- }
-
- RegexSynthContainerSP
- GetRegexTypeSyntheticsContainer ()
- {
- return m_synth_cont.GetRegexMatch();
- }
-
- SynthContainer&
- GetSyntheticsContainer ()
- {
- return m_synth_cont;
- }
-
- SynthContainer::MapValueType
- GetSyntheticAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForSyntheticAtIndex (size_t index);
+ SynthContainerSP GetTypeSyntheticsContainer() {
+ return m_synth_cont.GetExactMatch();
+ }
+
+ RegexSynthContainerSP GetRegexTypeSyntheticsContainer() {
+ return m_synth_cont.GetRegexMatch();
+ }
+
+ SynthContainer &GetSyntheticsContainer() { return m_synth_cont; }
+
+ SynthContainer::MapValueType GetSyntheticAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForSyntheticAtIndex(size_t index);
#endif // LLDB_DISABLE_PYTHON
-
- ValidatorContainerSP
- GetTypeValidatorsContainer ()
- {
- return m_validator_cont.GetExactMatch();
- }
-
- RegexValidatorContainerSP
- GetRegexTypeValidatorsContainer ()
- {
- return m_validator_cont.GetRegexMatch();
- }
-
- ValidatorContainer::MapValueType
- GetValidatorAtIndex (size_t index);
-
- lldb::TypeNameSpecifierImplSP
- GetTypeNameSpecifierForValidatorAtIndex (size_t index);
-
- bool
- IsEnabled () const
- {
- return m_enabled;
- }
-
- uint32_t
- GetEnabledPosition()
- {
- if (m_enabled == false)
- return UINT32_MAX;
- else
- return m_enabled_position;
- }
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeFormatImplSP& entry,
- uint32_t* reason = nullptr);
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeSummaryImplSP& entry,
- uint32_t* reason = nullptr);
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::SyntheticChildrenSP& entry,
- uint32_t* reason = nullptr);
-
- bool
- Get(ValueObject& valobj,
- const FormattersMatchVector& candidates,
- lldb::TypeValidatorImplSP& entry,
- uint32_t* reason = nullptr);
-
- void
- Clear (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- bool
- Delete (ConstString name,
- FormatCategoryItems items = ALL_ITEM_TYPES);
-
- uint32_t
- GetCount (FormatCategoryItems items = ALL_ITEM_TYPES);
-
- const char*
- GetName ()
- {
- return m_name.GetCString();
- }
-
- size_t
- GetNumLanguages ();
-
- lldb::LanguageType
- GetLanguageAtIndex (size_t idx);
-
- void
- AddLanguage (lldb::LanguageType lang);
-
- bool
- HasLanguage (lldb::LanguageType lang);
-
- std::string
- GetDescription ();
-
- bool
- AnyMatches(ConstString type_name,
- FormatCategoryItems items = ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- FormatCategoryItems* matching_type = nullptr);
-
- typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
-
- private:
- FormatContainer m_format_cont;
- SummaryContainer m_summary_cont;
- FilterContainer m_filter_cont;
+
+ ValidatorContainerSP GetTypeValidatorsContainer() {
+ return m_validator_cont.GetExactMatch();
+ }
+
+ RegexValidatorContainerSP GetRegexTypeValidatorsContainer() {
+ return m_validator_cont.GetRegexMatch();
+ }
+
+ ValidatorContainer::MapValueType GetValidatorAtIndex(size_t index);
+
+ lldb::TypeNameSpecifierImplSP
+ GetTypeNameSpecifierForValidatorAtIndex(size_t index);
+
+ bool IsEnabled() const { return m_enabled; }
+
+ uint32_t GetEnabledPosition() {
+ if (m_enabled == false)
+ return UINT32_MAX;
+ else
+ return m_enabled_position;
+ }
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::TypeFormatImplSP &entry, uint32_t *reason = nullptr);
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::TypeSummaryImplSP &entry, uint32_t *reason = nullptr);
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr);
+
+ bool Get(ValueObject &valobj, const FormattersMatchVector &candidates,
+ lldb::TypeValidatorImplSP &entry, uint32_t *reason = nullptr);
+
+ void Clear(FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ bool Delete(ConstString name, FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ uint32_t GetCount(FormatCategoryItems items = ALL_ITEM_TYPES);
+
+ const char *GetName() { return m_name.GetCString(); }
+
+ size_t GetNumLanguages();
+
+ lldb::LanguageType GetLanguageAtIndex(size_t idx);
+
+ void AddLanguage(lldb::LanguageType lang);
+
+ bool HasLanguage(lldb::LanguageType lang);
+
+ std::string GetDescription();
+
+ bool AnyMatches(ConstString type_name,
+ FormatCategoryItems items = ALL_ITEM_TYPES,
+ bool only_enabled = true,
+ const char **matching_category = nullptr,
+ FormatCategoryItems *matching_type = nullptr);
+
+ typedef std::shared_ptr<TypeCategoryImpl> SharedPointer;
+
+private:
+ FormatContainer m_format_cont;
+ SummaryContainer m_summary_cont;
+ FilterContainer m_filter_cont;
#ifndef LLDB_DISABLE_PYTHON
- SynthContainer m_synth_cont;
+ SynthContainer m_synth_cont;
#endif // LLDB_DISABLE_PYTHON
- ValidatorContainer m_validator_cont;
-
- bool m_enabled;
-
- IFormatChangeListener* m_change_listener;
-
- std::recursive_mutex m_mutex;
-
- ConstString m_name;
-
- std::vector<lldb::LanguageType> m_languages;
-
- uint32_t m_enabled_position;
-
- void
- Enable (bool value, uint32_t position);
-
- void
- Disable ()
- {
- Enable(false, UINT32_MAX);
- }
-
- bool
- IsApplicable (ValueObject& valobj);
-
- uint32_t
- GetLastEnabledPosition ()
- {
- return m_enabled_position;
- }
-
- void
- SetEnabledPosition (uint32_t p)
- {
- m_enabled_position = p;
- }
-
- friend class FormatManager;
- friend class LanguageCategory;
- friend class TypeCategoryMap;
-
- friend class FormattersContainer<ConstString, TypeFormatImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeFormatImpl>;
-
- friend class FormattersContainer<ConstString, TypeSummaryImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeSummaryImpl>;
-
- friend class FormattersContainer<ConstString, TypeFilterImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeFilterImpl>;
-
+ ValidatorContainer m_validator_cont;
+
+ bool m_enabled;
+
+ IFormatChangeListener *m_change_listener;
+
+ std::recursive_mutex m_mutex;
+
+ ConstString m_name;
+
+ std::vector<lldb::LanguageType> m_languages;
+
+ uint32_t m_enabled_position;
+
+ void Enable(bool value, uint32_t position);
+
+ void Disable() { Enable(false, UINT32_MAX); }
+
+ bool IsApplicable(ValueObject &valobj);
+
+ uint32_t GetLastEnabledPosition() { return m_enabled_position; }
+
+ void SetEnabledPosition(uint32_t p) { m_enabled_position = p; }
+
+ friend class FormatManager;
+ friend class LanguageCategory;
+ friend class TypeCategoryMap;
+
+ friend class FormattersContainer<ConstString, TypeFormatImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP, TypeFormatImpl>;
+
+ friend class FormattersContainer<ConstString, TypeSummaryImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP, TypeSummaryImpl>;
+
+ friend class FormattersContainer<ConstString, TypeFilterImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP, TypeFilterImpl>;
+
#ifndef LLDB_DISABLE_PYTHON
- friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>;
- friend class FormattersContainer<lldb::RegularExpressionSP, ScriptedSyntheticChildren>;
+ friend class FormattersContainer<ConstString, ScriptedSyntheticChildren>;
+ friend class FormattersContainer<lldb::RegularExpressionSP,
+ ScriptedSyntheticChildren>;
#endif // LLDB_DISABLE_PYTHON
-
- friend class FormattersContainer<ConstString, TypeValidatorImpl>;
- friend class FormattersContainer<lldb::RegularExpressionSP, TypeValidatorImpl>;
- };
-
+
+ friend class FormattersContainer<ConstString, TypeValidatorImpl>;
+ friend class FormattersContainer<lldb::RegularExpressionSP,
+ TypeValidatorImpl>;
+};
+
} // namespace lldb_private
#endif // lldb_TypeCategory_h_
Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategoryMap.h Tue Sep 6 15:57:50 2016
@@ -19,145 +19,107 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-public.h"
#include "lldb/DataFormatters/FormattersContainer.h"
#include "lldb/DataFormatters/TypeCategory.h"
namespace lldb_private {
- class TypeCategoryMap
- {
- private:
- typedef ConstString KeyType;
- typedef TypeCategoryImpl ValueType;
- typedef ValueType::SharedPointer ValueSP;
- typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
- typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
-
- public:
- typedef std::map<KeyType, ValueSP> MapType;
- typedef MapType::iterator MapIterator;
- typedef std::function<bool(const ValueSP&)> ForEachCallback;
-
- typedef uint32_t Position;
-
- static const Position First = 0;
- static const Position Default = 1;
- static const Position Last = UINT32_MAX;
-
- TypeCategoryMap (IFormatChangeListener* lst);
-
- void
- Add (KeyType name,
- const ValueSP& entry);
-
- bool
- Delete (KeyType name);
-
- bool
- Enable (KeyType category_name,
- Position pos = Default);
-
- bool
- Disable (KeyType category_name);
-
- bool
- Enable (ValueSP category,
- Position pos = Default);
-
- bool
- Disable (ValueSP category);
-
- void
- EnableAllCategories ();
-
- void
- DisableAllCategories ();
-
- void
- Clear ();
-
- bool
- Get (KeyType name,
- ValueSP& entry);
-
- bool
- Get (uint32_t pos,
- ValueSP& entry);
-
- void
- ForEach (ForEachCallback callback);
-
- lldb::TypeCategoryImplSP
- GetAtIndex (uint32_t);
-
- bool
- AnyMatches(ConstString type_name,
- TypeCategoryImpl::FormatCategoryItems items = TypeCategoryImpl::ALL_ITEM_TYPES,
- bool only_enabled = true,
- const char** matching_category = nullptr,
- TypeCategoryImpl::FormatCategoryItems* matching_type = nullptr);
-
- uint32_t
- GetCount ()
- {
- return m_map.size();
- }
-
- lldb::TypeFormatImplSP
- GetFormat (FormattersMatchData& match_data);
-
- lldb::TypeSummaryImplSP
- GetSummaryFormat (FormattersMatchData& match_data);
-
+class TypeCategoryMap {
+private:
+ typedef ConstString KeyType;
+ typedef TypeCategoryImpl ValueType;
+ typedef ValueType::SharedPointer ValueSP;
+ typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
+ typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
+
+public:
+ typedef std::map<KeyType, ValueSP> MapType;
+ typedef MapType::iterator MapIterator;
+ typedef std::function<bool(const ValueSP &)> ForEachCallback;
+
+ typedef uint32_t Position;
+
+ static const Position First = 0;
+ static const Position Default = 1;
+ static const Position Last = UINT32_MAX;
+
+ TypeCategoryMap(IFormatChangeListener *lst);
+
+ void Add(KeyType name, const ValueSP &entry);
+
+ bool Delete(KeyType name);
+
+ bool Enable(KeyType category_name, Position pos = Default);
+
+ bool Disable(KeyType category_name);
+
+ bool Enable(ValueSP category, Position pos = Default);
+
+ bool Disable(ValueSP category);
+
+ void EnableAllCategories();
+
+ void DisableAllCategories();
+
+ void Clear();
+
+ bool Get(KeyType name, ValueSP &entry);
+
+ bool Get(uint32_t pos, ValueSP &entry);
+
+ void ForEach(ForEachCallback callback);
+
+ lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
+
+ bool
+ AnyMatches(ConstString type_name,
+ TypeCategoryImpl::FormatCategoryItems items =
+ TypeCategoryImpl::ALL_ITEM_TYPES,
+ bool only_enabled = true, const char **matching_category = nullptr,
+ TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
+
+ uint32_t GetCount() { return m_map.size(); }
+
+ lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
+
+ lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
+
#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildren (FormattersMatchData& match_data);
+ lldb::SyntheticChildrenSP
+ GetSyntheticChildren(FormattersMatchData &match_data);
#endif
-
- lldb::TypeValidatorImplSP
- GetValidator(FormattersMatchData& match_data);
-
- private:
- class delete_matching_categories
- {
- lldb::TypeCategoryImplSP ptr;
- public:
- delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p)
- {}
-
- bool operator()(const lldb::TypeCategoryImplSP& other)
- {
- return ptr.get() == other.get();
- }
- };
-
- std::recursive_mutex m_map_mutex;
- IFormatChangeListener* listener;
-
- MapType m_map;
- ActiveCategoriesList m_active_categories;
-
- MapType& map ()
- {
- return m_map;
- }
-
- ActiveCategoriesList& active_list ()
- {
- return m_active_categories;
- }
-
- std::recursive_mutex &
- mutex()
- {
- return m_map_mutex;
- }
-
- friend class FormattersContainer<KeyType, ValueType>;
- friend class FormatManager;
- };
+
+ lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
+
+private:
+ class delete_matching_categories {
+ lldb::TypeCategoryImplSP ptr;
+
+ public:
+ delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {}
+
+ bool operator()(const lldb::TypeCategoryImplSP &other) {
+ return ptr.get() == other.get();
+ }
+ };
+
+ std::recursive_mutex m_map_mutex;
+ IFormatChangeListener *listener;
+
+ MapType m_map;
+ ActiveCategoriesList m_active_categories;
+
+ MapType &map() { return m_map; }
+
+ ActiveCategoriesList &active_list() { return m_active_categories; }
+
+ std::recursive_mutex &mutex() { return m_map_mutex; }
+
+ friend class FormattersContainer<KeyType, ValueType>;
+ friend class FormatManager;
+};
} // namespace lldb_private
#endif // lldb_TypeCategoryMap_h_
More information about the lldb-commits
mailing list