Page MenuHomePhabricator

D64661.id209574.diff
No OneTemporary

File Metadata

Created
Thu, Nov 14, 7:36 PM

D64661.id209574.diff

Index: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
===================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
@@ -80,20 +80,29 @@
lldb::offset_t Extract(const lldb_private::DataExtractor &data,
lldb::offset_t offset);
+ /// Object name in the archive.
+ lldb_private::ConstString ar_name;
- lldb_private::ConstString ar_name; // name
- uint32_t ar_date; // modification time
- uint16_t ar_uid; // user id
- uint16_t ar_gid; // group id
- uint16_t ar_mode; // octal file permissions
- uint32_t ar_size; // size in bytes
- lldb::offset_t ar_file_offset; // file offset in bytes from the beginning of
- // the file of the object data
- lldb::offset_t ar_file_size; // length of the object data
-
- typedef std::vector<Object> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ /// Object modification time in the archive.
+ uint32_t modification_time;
+
+ /// Object user id in the archive.
+ uint16_t uid;
+
+ /// Object group id in the archive.
+ uint16_t gid;
+
+ /// Object octal file permissions in the archive.
+ uint16_t mode;
+
+ /// Object size in bytes in the archive.
+ uint32_t size;
+
+ /// File offset in bytes from the beginning of the file of the object data.
+ lldb::offset_t file_offset;
+
+ /// Length of the object data.
+ lldb::offset_t file_size;
};
class Archive {
@@ -135,7 +144,9 @@
lldb::offset_t GetFileOffset() const { return m_file_offset; }
- const llvm::sys::TimePoint<> &GetModificationTime() { return m_time; }
+ const llvm::sys::TimePoint<> &GetModificationTime() {
+ return m_modification_time;
+ }
const lldb_private::ArchSpec &GetArchitecture() const { return m_arch; }
@@ -149,9 +160,9 @@
typedef lldb_private::UniqueCStringMap<uint32_t> ObjectNameToIndexMap;
// Member Variables
lldb_private::ArchSpec m_arch;
- llvm::sys::TimePoint<> m_time;
+ llvm::sys::TimePoint<> m_modification_time;
lldb::offset_t m_file_offset;
- Object::collection m_objects;
+ std::vector<Object> m_objects;
ObjectNameToIndexMap m_object_name_to_index_map;
lldb_private::DataExtractor m_data; ///< The data for this object container
///so we don't lose data if the .a files
Index: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
===================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -41,18 +41,18 @@
using namespace lldb_private;
ObjectContainerBSDArchive::Object::Object()
- : ar_name(), ar_date(0), ar_uid(0), ar_gid(0), ar_mode(0), ar_size(0),
- ar_file_offset(0), ar_file_size(0) {}
+ : ar_name(), modification_time(0), uid(0), gid(0), mode(0), size(0),
+ file_offset(0), file_size(0) {}
void ObjectContainerBSDArchive::Object::Clear() {
ar_name.Clear();
- ar_date = 0;
- ar_uid = 0;
- ar_gid = 0;
- ar_mode = 0;
- ar_size = 0;
- ar_file_offset = 0;
- ar_file_size = 0;
+ modification_time = 0;
+ uid = 0;
+ gid = 0;
+ mode = 0;
+ size = 0;
+ file_offset = 0;
+ file_size = 0;
}
lldb::offset_t
@@ -102,19 +102,19 @@
}
str.assign((const char *)data.GetData(&offset, 12), 12);
- ar_date = strtoul(str.c_str(), &err, 10);
+ modification_time = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 6), 6);
- ar_uid = strtoul(str.c_str(), &err, 10);
+ uid = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 6), 6);
- ar_gid = strtoul(str.c_str(), &err, 10);
+ gid = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 8), 8);
- ar_mode = strtoul(str.c_str(), &err, 8);
+ mode = strtoul(str.c_str(), &err, 8);
str.assign((const char *)data.GetData(&offset, 10), 10);
- ar_size = strtoul(str.c_str(), &err, 10);
+ size = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 2), 2);
if (str == ARFMAG) {
@@ -126,8 +126,8 @@
str.assign((const char *)ar_name_ptr, ar_name_len);
ar_name.SetCString(str.c_str());
}
- ar_file_offset = offset;
- ar_file_size = ar_size - ar_name_len;
+ file_offset = offset;
+ file_size = size - ar_name_len;
return offset;
}
return LLDB_INVALID_OFFSET;
@@ -137,8 +137,8 @@
const llvm::sys::TimePoint<> &time,
lldb::offset_t file_offset,
lldb_private::DataExtractor &data)
- : m_arch(arch), m_time(time), m_file_offset(file_offset), m_objects(),
- m_data(data) {}
+ : m_arch(arch), m_modification_time(time), m_file_offset(file_offset),
+ m_objects(), m_data(data) {}
ObjectContainerBSDArchive::Archive::~Archive() {}
@@ -157,7 +157,7 @@
m_objects.push_back(obj);
// Insert all of the C strings out of order for now...
m_object_name_to_index_map.Append(obj.ar_name, obj_idx);
- offset += obj.ar_file_size;
+ offset += obj.file_size;
obj.Clear();
} while (data.ValidOffset(offset));
@@ -169,27 +169,27 @@
ObjectContainerBSDArchive::Object *
ObjectContainerBSDArchive::Archive::FindObject(
- ConstString object_name,
- const llvm::sys::TimePoint<> &object_mod_time) {
+ ConstString object_name, const llvm::sys::TimePoint<> &object_mod_time) {
const ObjectNameToIndexMap::Entry *match =
m_object_name_to_index_map.FindFirstValueForName(object_name);
- if (match) {
- if (object_mod_time != llvm::sys::TimePoint<>()) {
- const uint64_t object_date = llvm::sys::toTimeT(object_mod_time);
- if (m_objects[match->value].ar_date == object_date)
- return &m_objects[match->value];
- const ObjectNameToIndexMap::Entry *next_match =
- m_object_name_to_index_map.FindNextValueForName(match);
- while (next_match) {
- if (m_objects[next_match->value].ar_date == object_date)
- return &m_objects[next_match->value];
- next_match =
- m_object_name_to_index_map.FindNextValueForName(next_match);
- }
- } else {
- return &m_objects[match->value];
- }
+ if (!match)
+ return nullptr;
+ if (object_mod_time == llvm::sys::TimePoint<>())
+ return &m_objects[match->value];
+
+ const uint64_t object_modification_date = llvm::sys::toTimeT(object_mod_time);
+ if (m_objects[match->value].modification_time == object_modification_date)
+ return &m_objects[match->value];
+
+ const ObjectNameToIndexMap::Entry *next_match =
+ m_object_name_to_index_map.FindNextValueForName(match);
+ while (next_match) {
+ if (m_objects[next_match->value].modification_time ==
+ object_modification_date)
+ return &m_objects[next_match->value];
+ next_match = m_object_name_to_index_map.FindNextValueForName(next_match);
}
+
return nullptr;
}
@@ -425,11 +425,10 @@
Object *object = m_archive_sp->FindObject(
module_sp->GetObjectName(), module_sp->GetObjectModificationTime());
if (object) {
- lldb::offset_t data_offset = object->ar_file_offset;
+ lldb::offset_t data_offset = object->file_offset;
return ObjectFile::FindPlugin(
- module_sp, file, m_offset + object->ar_file_offset,
- object->ar_file_size, m_archive_sp->GetData().GetSharedDataBuffer(),
- data_offset);
+ module_sp, file, m_offset + object->file_offset, object->file_size,
+ m_archive_sp->GetData().GetSharedDataBuffer(), data_offset);
}
}
}
@@ -478,16 +477,15 @@
const Object *object = archive_sp->GetObjectAtIndex(idx);
if (object) {
const lldb::offset_t object_file_offset =
- file_offset + object->ar_file_offset;
- if (object->ar_file_offset < file_size &&
- file_size > object_file_offset) {
+ file_offset + object->file_offset;
+ if (object->file_offset < file_size && file_size > object_file_offset) {
if (ObjectFile::GetModuleSpecifications(
file, object_file_offset, file_size - object_file_offset,
specs)) {
ModuleSpec &spec =
specs.GetModuleSpecRefAtIndex(specs.GetSize() - 1);
llvm::sys::TimePoint<> object_mod_time(
- std::chrono::seconds(object->ar_date));
+ std::chrono::seconds(object->modification_time));
spec.GetObjectName() = object->ar_name;
spec.SetObjectOffset(object_file_offset);
spec.SetObjectSize(file_size - object_file_offset);

Event Timeline