[Lldb-commits] [lldb] fdbb5a7 - [lldb] Add code and data address mask to Process
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 16 12:31:03 PDT 2021
Author: Jonas Devlieghere
Date: 2021-04-16T12:30:54-07:00
New Revision: fdbb5a7a91b00d1e4a9a16fee96763917a411fff
URL: https://github.com/llvm/llvm-project/commit/fdbb5a7a91b00d1e4a9a16fee96763917a411fff
DIFF: https://github.com/llvm/llvm-project/commit/fdbb5a7a91b00d1e4a9a16fee96763917a411fff.diff
LOG: [lldb] Add code and data address mask to Process
Add a code and data address mask to Process with respective getters and
setters and a setting that allows the user to specify the mast as a
number of addressable bits. The masks will be used by FixCodeAddress and
FixDataAddress respectively in the ABI classes.
Differential revision: https://reviews.llvm.org/D100515
Added:
Modified:
lldb/include/lldb/Target/Process.h
lldb/source/Target/Process.cpp
lldb/source/Target/TargetProperties.td
Removed:
################################################################################
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index abd0d39fe9699..0a2a6f6dfb5b8 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -77,6 +77,8 @@ class ProcessProperties : public Properties {
Args GetExtraStartupCommands() const;
void SetExtraStartupCommands(const Args &args);
FileSpec GetPythonOSPluginPath() const;
+ uint32_t GetVirtualAddressableBits() const;
+ void SetVirtualAddressableBits(uint32_t bits);
void SetPythonOSPluginPath(const FileSpec &file);
bool GetIgnoreBreakpointsInExpressions() const;
void SetIgnoreBreakpointsInExpressions(bool ignore);
@@ -1330,6 +1332,17 @@ class Process : public std::enable_shared_from_this<Process>,
virtual void DidExit() {}
+ lldb::addr_t GetCodeAddressMask();
+ lldb::addr_t GetDataAddressMask();
+
+ void SetCodeAddressMask(lldb::addr_t code_address_mask) {
+ m_code_address_mask = code_address_mask;
+ }
+
+ void SetDataAddressMask(lldb::addr_t data_address_mask) {
+ m_data_address_mask = data_address_mask;
+ }
+
/// Get the Modification ID of the process.
///
/// \return
@@ -2878,6 +2891,13 @@ void PruneThreadPlans();
/// from looking up or creating things during or after a finalize call.
std::atomic<bool> m_finalizing;
+ /// Mask for code an data addresses. The default value (0) means no mask is
+ /// set.
+ /// @{
+ lldb::addr_t m_code_address_mask = 0;
+ lldb::addr_t m_data_address_mask = 0;
+ /// @}
+
bool m_clear_thread_plans_on_stop;
bool m_force_next_event_delivery;
lldb::StateType m_last_broadcast_state; /// This helps with the Public event
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 986df94e73beb..9f39e78e5d726 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -200,6 +200,16 @@ FileSpec ProcessProperties::GetPythonOSPluginPath() const {
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
}
+uint32_t ProcessProperties::GetVirtualAddressableBits() const {
+ const uint32_t idx = ePropertyVirtualAddressableBits;
+ return m_collection_sp->GetPropertyAtIndexAsUInt64(
+ nullptr, idx, g_process_properties[idx].default_uint_value);
+}
+
+void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) {
+ const uint32_t idx = ePropertyVirtualAddressableBits;
+ m_collection_sp->SetPropertyAtIndexAsUInt64(nullptr, idx, bits);
+}
void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) {
const uint32_t idx = ePropertyPythonOSPluginPath;
m_collection_sp->SetPropertyAtIndexAsFileSpec(nullptr, idx, file);
@@ -5547,6 +5557,26 @@ void Process::Flush() {
m_queue_list_stop_id = 0;
}
+lldb::addr_t Process::GetCodeAddressMask() {
+ if (m_code_address_mask == 0) {
+ if (uint32_t number_of_addressable_bits = GetVirtualAddressableBits()) {
+ lldb::addr_t address_mask = ~((1ULL << number_of_addressable_bits) - 1);
+ SetCodeAddressMask(address_mask);
+ }
+ }
+ return m_code_address_mask;
+}
+
+lldb::addr_t Process::GetDataAddressMask() {
+ if (m_data_address_mask == 0) {
+ if (uint32_t number_of_addressable_bits = GetVirtualAddressableBits()) {
+ lldb::addr_t address_mask = ~((1ULL << number_of_addressable_bits) - 1);
+ SetDataAddressMask(address_mask);
+ }
+ }
+ return m_data_address_mask;
+}
+
void Process::DidExec() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td
index e22f94069131a..a3634a0bd54f1 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -233,6 +233,9 @@ let Definition = "process" in {
def SteppingRunsAllThreads: Property<"run-all-threads", "Boolean">,
DefaultFalse,
Desc<"If true, stepping operations will run all threads. This is equivalent to setting the run-mode option to 'all-threads'.">;
+ def VirtualAddressableBits: Property<"virtual-addressable-bits", "UInt64">,
+ DefaultUnsignedValue<0>,
+ Desc<"The number of bits used for addressing. If the value is 39, then bits 0..38 are used for addressing. The default value of 0 means unspecified.">;
}
let Definition = "platform" in {
More information about the lldb-commits
mailing list