augusto2112 created this revision.
augusto2112 added reviewers: aprantl, jasonmolenda.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100338
Files:
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td
Index: lldb/source/Target/TargetProperties.td
===================================================================
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -175,6 +175,9 @@
def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
DefaultFalse,
Desc<"Enable debugging of LLDB-internal utility expressions.">;
+ def FetchReadonlySectionsFromFileCache:
Property<"fetch-readonly-sections-from-file-cache", "Boolean">,
+ DefaultTrue,
+ Desc<"Enables reading bytes from the file cache instead of process when
the address LLDB is reading from falls in a readable but not writable section">;
}
let Definition = "process_experimental" in {
Index: lldb/source/Target/Target.cpp
===================================================================
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1753,6 +1753,15 @@
if (!resolved_addr.IsValid())
resolved_addr = addr;
+ if (GetFetchReadonlySectionsFromFileCache()) {
+ SectionSP section_sp(addr.GetSection());
+ if (section_sp) {
+ auto permissions = section_sp->GetPermissions();
+ prefer_file_cache |= (permissions & ePermissionsWritable) == 0 &&
+ (permissions & ePermissionsReadable) == 1;
+ }
+ }
+
if (prefer_file_cache) {
bytes_read = ReadMemoryFromFileCache(resolved_addr, dst, dst_len, error);
if (bytes_read > 0)
@@ -4355,6 +4364,17 @@
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, debug);
}
+bool TargetProperties::GetFetchReadonlySectionsFromFileCache() const {
+ const uint32_t idx = ePropertyFetchReadonlySectionsFromFileCache;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetFetchReadonlySectionsFromFileCache(bool b) {
+ const uint32_t idx = ePropertyFetchReadonlySectionsFromFileCache;
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
// Target::TargetEventData
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
Index: lldb/include/lldb/Target/Target.h
===================================================================
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -231,6 +231,11 @@
bool GetDebugUtilityExpression() const;
+ bool GetFetchReadonlySectionsFromFileCache() const;
+
+ void SetFetchReadonlySectionsFromFileCache(bool b);
+
+
private:
// Callbacks for m_launch_info.
void Arg0ValueChangedCallback();
Index: lldb/source/Target/TargetProperties.td
===================================================================
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -175,6 +175,9 @@
def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
DefaultFalse,
Desc<"Enable debugging of LLDB-internal utility expressions.">;
+ def FetchReadonlySectionsFromFileCache: Property<"fetch-readonly-sections-from-file-cache", "Boolean">,
+ DefaultTrue,
+ Desc<"Enables reading bytes from the file cache instead of process when the address LLDB is reading from falls in a readable but not writable section">;
}
let Definition = "process_experimental" in {
Index: lldb/source/Target/Target.cpp
===================================================================
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -1753,6 +1753,15 @@
if (!resolved_addr.IsValid())
resolved_addr = addr;
+ if (GetFetchReadonlySectionsFromFileCache()) {
+ SectionSP section_sp(addr.GetSection());
+ if (section_sp) {
+ auto permissions = section_sp->GetPermissions();
+ prefer_file_cache |= (permissions & ePermissionsWritable) == 0 &&
+ (permissions & ePermissionsReadable) == 1;
+ }
+ }
+
if (prefer_file_cache) {
bytes_read = ReadMemoryFromFileCache(resolved_addr, dst, dst_len, error);
if (bytes_read > 0)
@@ -4355,6 +4364,17 @@
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, debug);
}
+bool TargetProperties::GetFetchReadonlySectionsFromFileCache() const {
+ const uint32_t idx = ePropertyFetchReadonlySectionsFromFileCache;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetFetchReadonlySectionsFromFileCache(bool b) {
+ const uint32_t idx = ePropertyFetchReadonlySectionsFromFileCache;
+ m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
// Target::TargetEventData
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
Index: lldb/include/lldb/Target/Target.h
===================================================================
--- lldb/include/lldb/Target/Target.h
+++ lldb/include/lldb/Target/Target.h
@@ -231,6 +231,11 @@
bool GetDebugUtilityExpression() const;
+ bool GetFetchReadonlySectionsFromFileCache() const;
+
+ void SetFetchReadonlySectionsFromFileCache(bool b);
+
+
private:
// Callbacks for m_launch_info.
void Arg0ValueChangedCallback();
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits